aboutsummaryrefslogtreecommitdiff
path: root/mod/mod-repository-root.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-03-16 12:51:24 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-03-16 12:51:24 +0300
commitbed7ade3fa57ef3a7d4e8bd99c35aecb1f414bed (patch)
treeba2158ffeea2e23d7150566bc9773bdbb060ab93 /mod/mod-repository-root.cxx
parentf0c834ed57ef3afbbed2a4baacbab19fe6e7a6fd (diff)
Fix brep module to properly handle request parameters parsing exceptions
Diffstat (limited to 'mod/mod-repository-root.cxx')
-rw-r--r--mod/mod-repository-root.cxx55
1 files changed, 28 insertions, 27 deletions
diff --git a/mod/mod-repository-root.cxx b/mod/mod-repository-root.cxx
index 84c1ed1..5bb5b69 100644
--- a/mod/mod-repository-root.cxx
+++ b/mod/mod-repository-root.cxx
@@ -154,34 +154,35 @@ namespace brep
// Delegate the request handling to the sub-module. Intercept exception
// handling to add sub-module attribution.
//
- auto handle = [&rs, this](module& m, request& rq, const char* name) -> bool
+ auto handle =
+ [&rs, this] (module& m, request& rq, const char* name) -> bool
+ {
+ try
{
- try
- {
- return m.handle (rq, rs, *log_);
- }
- catch (const invalid_request&)
- {
- // Preserve invalid_request exception type, so the web server can
- // properly respond to the client with a 4XX error code.
- //
- throw;
- }
- catch (const std::exception& e)
- {
- // All exception types inherited from std::exception (and different
- // from invalid_request) are handled by the web server as
- // std::exception. The only sensible way to handle them is to respond
- // to the client with the internal server error (500) code. By that
- // reason it is valid to reduce all these types to a single one.
- // Note that the server_error exception is handled internally by the
- // module::handle() function call.
- //
- ostringstream os;
- os << name << ": " << e;
- throw runtime_error (os.str ());
- }
- };
+ return m.handle (rq, rs, *log_);
+ }
+ catch (const invalid_request&)
+ {
+ // Preserve invalid_request exception type, so the web server can
+ // properly respond to the client with a 4XX error code.
+ //
+ throw;
+ }
+ catch (const std::exception& e)
+ {
+ // All exception types inherited from std::exception (and different
+ // from invalid_request) are handled by the web server as
+ // std::exception. The only sensible way to handle them is to respond
+ // to the client with the internal server error (500) code. By that
+ // reason it is valid to reduce all these types to a single one. Note
+ // that the server_error exception is handled internally by the
+ // module::handle() function call.
+ //
+ ostringstream os;
+ os << name << ": " << e;
+ throw runtime_error (os.str ());
+ }
+ };
if (lpath.empty ())
{