Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[C++][Pistache] Catch HttpError when user-provided handler has thrown
This allows for returning valid http code through exception
  • Loading branch information
muttleyxd committed Jun 2, 2020
commit a8ff68dfb6cb77054cae0e672f796c61303f7057
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ void {{classname}}::{{operationIdSnakeCase}}_handler(const Pistache::Rest::Reque
//send a 400 error
response.send(Pistache::Http::Code::Bad_Request, e.what());
return;
} catch (Pistache::Http::HttpError &e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception &e) {
//send a 500 error
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
Expand Down