-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to debug the handlers? #146
Comments
Hi! Looks like you get a It's hard to help you because I don't know anything about your code. You can try to place the code in your request-handler into try-catch block: auto my_request_handler(const restinio::request_handle_t & req) {
try {
... // Your code here.
}
catch(const std::exception & x) {
std::cerr << "Oops! " << x.what() << std::endl; // (1)
}
} Then set a breakpoint at (1). |
Is there an MACRO -- not to catch the exception and let the app core dump, then let me check the error stack (in gdb)? |
No, there is no such a macro. You can comment try/catch blocks here: restinio/dev/restinio/impl/connection.hpp Lines 741 to 749 in 0052518
|
Breakpoint at (1) won't provide the error stack. |
Thanks. I comment/uncomment using
|
Oops. Ok. Let's try something like that: class dummy_breakpoint {
bool commited_{false};
public:
dummy_breakpoint() = default;
~dummy_breakpoint() { if(!commited_) std::abort(); } // or just throw std::runtime_error("my exception");
void commit() { commited_ = true; }
};
// Then in your request-handler:
auto my_request_handler(const restinio::request_handle_t & req) {
dummy_breakpoint breakpoint;
...
const auto res = req->create_response(...)...;
dummy_breakpoint.commit();
return res;
} |
My app showed me an error message:
I didn't know where the error cames from (even I compiled in debug mode and run in gdb). What should I do?
The text was updated successfully, but these errors were encountered: