mirror of
https://github.com/yhirose/cpp-httplib
synced 2024-11-21 14:29:10 -07:00
fix double ref and case of exceptions that are not std::exception
This commit is contained in:
parent
72d3f4896a
commit
d4ab2fa0e6
1 changed files with 9 additions and 3 deletions
12
httplib.h
12
httplib.h
|
@ -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_ptr &ep)>;
|
std::function<void(const Request &, Response &, std::exception_ptr ep)>;
|
||||||
|
|
||||||
enum class HandlerResponse {
|
enum class HandlerResponse {
|
||||||
Handled,
|
Handled,
|
||||||
|
@ -5741,8 +5741,14 @@ Server::process_request(Stream &strm, bool close_connection,
|
||||||
res.set_header("EXCEPTION_WHAT", e.what());
|
res.set_header("EXCEPTION_WHAT", e.what());
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
res.status = 500;
|
if (exception_handler_) {
|
||||||
res.set_header("EXCEPTION_WHAT", "UNKNOWN");
|
auto ep = std::current_exception();
|
||||||
|
exception_handler_(req, res, ep);
|
||||||
|
routed = true;
|
||||||
|
} else {
|
||||||
|
res.status = 500;
|
||||||
|
res.set_header("EXCEPTION_WHAT", "UNKNOWN");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue