Skip to content

Commit

Permalink
HttpException status not handled by modules #63
Browse files Browse the repository at this point in the history
  • Loading branch information
Tazura committed Nov 5, 2018
1 parent 6d035e2 commit b5ab161
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions modules/share/ngrest_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,16 @@ class ModMessageCallback: public ngrest::MessageCallback

void error(const ngrest::Exception& error) override
{
if (httpResponse->statusCode == ngrest::HTTP_STATUS_UNDEFINED)
httpResponse->statusCode = ngrest::HTTP_STATUS_500_INTERNAL_SERVER_ERROR;
if (httpResponse->statusCode == ngrest::HTTP_STATUS_UNDEFINED) {
try {
throw; // we're called from catch block
} catch (const ngrest::HttpException& e) {
httpResponse->statusCode = e.getHttpStatus();
} catch (...) {
httpResponse->statusCode = ngrest::HTTP_STATUS_500_INTERNAL_SERVER_ERROR;
}
}

httpResponse->poolBody->reset();
httpResponse->poolBody->putCString(error.what());
}
Expand Down

0 comments on commit b5ab161

Please sign in to comment.