aboutsummaryrefslogtreecommitdiffstats
path: root/amalgamate
diff options
context:
space:
mode:
authoripknHama <ipknhama@gmail.com>2014-12-12 07:29:08 +0900
committeripknHama <ipknhama@gmail.com>2014-12-12 07:29:08 +0900
commitf6fdf68fe27b55854198449ac4775bd52dafb1c6 (patch)
tree3b57cceadd6a9f4c8df03b12b73782e7c905b06b /amalgamate
parentaa37844ccaa0dadb5de277eea063c82c22f91bbb (diff)
parenta1751967c33b78039fc0b602ea6c408b82346df2 (diff)
downloadcrow-f6fdf68fe27b55854198449ac4775bd52dafb1c6.tar.gz
crow-f6fdf68fe27b55854198449ac4775bd52dafb1c6.zip
Merge branch 'try-catch-handle' of https://github.com/acron0/crow into acron0-try-catch-handle
Conflicts: amalgamate/crow_all.h
Diffstat (limited to 'amalgamate')
-rw-r--r--amalgamate/crow_all.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/amalgamate/crow_all.h b/amalgamate/crow_all.h
index 911d15d..ed5ee0d 100644
--- a/amalgamate/crow_all.h
+++ b/amalgamate/crow_all.h
@@ -6966,7 +6966,25 @@ public:
CROW_LOG_DEBUG << "Matched rule '" << ((TaggedRule<>*)rules_[rule_index].get())->rule_ << "' " << (uint32_t)req.method << " / " << rules_[rule_index]->methods();
- rules_[rule_index]->handle(req, res, found.second);
+ // any uncaught exceptions become 500s
+ try
+ {
+ rules_[rule_index]->handle(req, res, found.second);
+ }
+ catch(std::exception& e)
+ {
+ CROW_LOG_ERROR << "An uncaught exception occurred: " << e.what();
+ res = response(500);
+ res.end();
+ return;
+ }
+ catch(...)
+ {
+ CROW_LOG_ERROR << "An uncaught exception occurred. The type was unknown so no information was available.";
+ res = response(500);
+ res.end();
+ return;
+ }
}
void debug_print()