|
|
@@ -614,7 +614,7 @@ public:
|
|
|
using Handler = std::function<void(const Request &, Response &)>;
|
|
|
|
|
|
using ExceptionHandler =
|
|
|
- std::function<void(const Request &, Response &, std::exception &e)>;
|
|
|
+ std::function<void(const Request &, Response &, std::exception_ptr ep)>;
|
|
|
|
|
|
enum class HandlerResponse {
|
|
|
Handled,
|
|
|
@@ -5721,15 +5721,22 @@ Server::process_request(Stream &strm, bool close_connection,
|
|
|
routed = routing(req, res, strm);
|
|
|
} catch (std::exception &e) {
|
|
|
if (exception_handler_) {
|
|
|
- exception_handler_(req, res, e);
|
|
|
+ auto ep = std::current_exception();
|
|
|
+ exception_handler_(req, res, ep);
|
|
|
routed = true;
|
|
|
} else {
|
|
|
res.status = 500;
|
|
|
res.set_header("EXCEPTION_WHAT", e.what());
|
|
|
}
|
|
|
} catch (...) {
|
|
|
- res.status = 500;
|
|
|
- res.set_header("EXCEPTION_WHAT", "UNKNOWN");
|
|
|
+ if (exception_handler_) {
|
|
|
+ auto ep = std::current_exception();
|
|
|
+ exception_handler_(req, res, ep);
|
|
|
+ routed = true;
|
|
|
+ } else {
|
|
|
+ res.status = 500;
|
|
|
+ res.set_header("EXCEPTION_WHAT", "UNKNOWN");
|
|
|
+ }
|
|
|
}
|
|
|
#endif
|
|
|
|