Update httplib.h

use std::exception_ptr
This commit is contained in:
Kai Aoki 2022-07-12 00:10:57 +09:00
parent 5e6f973b99
commit 72d3f4896a

View file

@ -616,7 +616,7 @@ public:
using Handler = std::function<void(const Request &, Response &)>; using Handler = std::function<void(const Request &, Response &)>;
using ExceptionHandler = using ExceptionHandler =
std::function<void(const Request &, Response &, std::exception &e)>; std::function<void(const Request &, Response &, std::exception_ptr &ep)>;
enum class HandlerResponse { enum class HandlerResponse {
Handled, Handled,
@ -5733,7 +5733,8 @@ Server::process_request(Stream &strm, bool close_connection,
routed = routing(req, res, strm); routed = routing(req, res, strm);
} catch (std::exception &e) { } catch (std::exception &e) {
if (exception_handler_) { if (exception_handler_) {
exception_handler_(req, res, e); auto ep = std::current_exception();
exception_handler_(req, res, ep);
routed = true; routed = true;
} else { } else {
res.status = 500; res.status = 500;