cpptrace icon indicating copy to clipboard operation
cpptrace copied to clipboard

Improve handling of errors

Open LouisClt opened this issue 10 months ago • 1 comments

Hello,

First of all, thanks for this project. We use CPPtrace in our software under windows (with dbghelp), for better tracing in case of particular events (for instance).

Sometimes when we ask for a trace, the get_frame_object_info fails and go into src/binary/object.cpp line158 to do : std::fprintf(stderr, "%s\n", std::system_error(GetLastError(), std::system_category()).what());

This is a problem for us as it goes into the stderr shared across the whole program and cause users to wonder what this error is and where do it come from (and more importantly : is it serious ?).

For instance this is the kind of message we get : Le module spÚcifiÚ est introuvable. which should translate to The specified module cannot be found. .

Could we imagine that instead of calling a naked std::fprintf, we provide a callback to log/handle the errors of this kind accordingly ?

Thanks and best regards

LouisClt avatar Apr 16 '25 15:04 LouisClt

Hi, thanks for opening this and sorry you ran into this. It would definitely be better for cpptrace to not print stuff like this. I’m not sure the best way for cpptrace to report its own internal errors, I think some sort of logging callback could be reasonable. For the time being removing the print is straightforward and I’ll do so as well as looking for anywhere else in the codebase this is done.

jeremy-rifkin avatar Apr 16 '25 16:04 jeremy-rifkin

I've released the next version of cpptrace with better handling here

jeremy-rifkin avatar Jun 12 '25 17:06 jeremy-rifkin