diff options
author | ipknHama <ipknhama@gmail.com> | 2014-12-12 07:30:58 +0900 |
---|---|---|
committer | ipknHama <ipknhama@gmail.com> | 2014-12-12 07:30:58 +0900 |
commit | aa36502cf27af4457fb57f04c1e612c521978c5e (patch) | |
tree | 3b57cceadd6a9f4c8df03b12b73782e7c905b06b /include/routing.h | |
parent | aa37844ccaa0dadb5de277eea063c82c22f91bbb (diff) | |
parent | f6fdf68fe27b55854198449ac4775bd52dafb1c6 (diff) | |
download | crow-aa36502cf27af4457fb57f04c1e612c521978c5e.tar.gz crow-aa36502cf27af4457fb57f04c1e612c521978c5e.zip |
Merge branch 'acron0-try-catch-handle'
Diffstat (limited to 'include/routing.h')
-rw-r--r-- | include/routing.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/routing.h b/include/routing.h index f074b69..a2e7856 100644 --- a/include/routing.h +++ b/include/routing.h @@ -655,7 +655,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() |