Add backtrace to Error constructor #309

Open
opened 2024-05-12 18:02:51 +00:00 by puck · 2 comments
Owner

It's a pain to try and figure out where a mystery error, like "invalid character in base64 string:" comes from. This could be made much more simple by extracting a stacktrace whenever an error is constructed, and printing it out, along with the actual error message.

It's a pain to try and figure out where a mystery error, like "invalid character in base64 string:" comes from. This could be made much more simple by extracting a stacktrace whenever an error is constructed, and printing it out, along with the actual error message.
puck added the
ux
label 2024-05-12 18:03:24 +00:00
Owner

Shouldn't be hard; we did this for HintFmt:

std::cerr << boost::stacktrace::stacktrace() << std::endl;

Though if we're going to make more regular use of backtraces we may want to use something like https://github.com/jeremy-rifkin/cpptrace

Shouldn't be hard; we did this for HintFmt: https://git.lix.systems/lix-project/lix/src/commit/4b35e6a75e35e0f79bdadfd5e0d44bc870dcc135/src/libutil/fmt.hh#L175 Though if we're going to make more regular use of backtraces we may want to use something like https://github.com/jeremy-rifkin/cpptrace
qyriad added the
E/easy
label 2024-05-12 19:08:11 +00:00
Owner

an alternative i found is using std::source_location in a default of an argument of the constructor to do the equivalent of rust's #[track_caller]: very cheap at runtime

and this may be important for cases where we are abusing exceptions for control flow? unsure.

an alternative i found is using std::source_location in a default of an argument of the constructor to do the equivalent of rust's `#[track_caller]`: very cheap at runtime and this may be important for cases where we are abusing exceptions for control flow? unsure.
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#309
No description provided.