Merge branch 'master' into r1-toolcall

This commit is contained in:
Olivier Chafik 2025-02-05 01:10:45 +00:00 committed by GitHub
commit 1f1f06aa26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 126 additions and 54 deletions

View file

@ -3357,6 +3357,8 @@ static void log_server_request(const httplib::Request & req, const httplib::Resp
return;
}
// reminder: this function is not covered by httplib's exception handler; if someone does more complicated stuff, think about wrapping it in try-catch
LOG_INF("request: %s %s %s %d\n", req.method.c_str(), req.path.c_str(), req.remote_addr.c_str(), res.status);
LOG_DBG("request: %s\n", req.body.c_str());
@ -3443,9 +3445,13 @@ int main(int argc, char ** argv) {
message = "Unknown Exception";
}
json formatted_error = format_error_response(message, ERROR_TYPE_SERVER);
LOG_WRN("got exception: %s\n", formatted_error.dump().c_str());
res_error(res, formatted_error);
try {
json formatted_error = format_error_response(message, ERROR_TYPE_SERVER);
LOG_WRN("got exception: %s\n", formatted_error.dump().c_str());
res_error(res, formatted_error);
} catch (const std::exception & e) {
LOG_ERR("got another exception: %s | while hanlding exception: %s\n", e.what(), message.c_str());
}
});
svr->set_error_handler([&res_error](const httplib::Request &, httplib::Response & res) {