From 8cce0bab4b95427d3f59182d06fa1e0af13d27f5 Mon Sep 17 00:00:00 2001 From: "Rojo (AJPanda's Assistant)" <0xnftnut@gmail.com> Date: Sun, 1 Mar 2026 15:26:22 -0600 Subject: [PATCH] fix: error handler hiding real errors behind 'unknown endpoint' --- main.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 482255a..3a1f3d2 100644 --- a/main.cpp +++ b/main.cpp @@ -291,7 +291,16 @@ int main(int argc, char** argv) { svr.set_error_handler([](const httplib::Request& req, httplib::Response& res) { if (req.path.rfind("/api/", 0) == 0 && res.body.empty()) { json j; - j["error"] = "unknown endpoint: " + req.method + " " + req.path; + if (res.status == 404) { + j["error"] = "unknown endpoint: " + req.method + " " + req.path; + } else { + j["error"] = "internal error on: " + req.method + " " + req.path + + " (status " + std::to_string(res.status) + ")"; + auto it = res.headers.find("EXCEPTION_WHAT"); + if (it != res.headers.end()) { + j["detail"] = it->second; + } + } res.set_content(j.dump(), "application/json"); } });