Skip to content
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

Add more context to errors #266

Closed
d-e-s-o opened this issue Jul 21, 2023 · 1 comment
Closed

Add more context to errors #266

d-e-s-o opened this issue Jul 21, 2023 · 1 comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@d-e-s-o
Copy link
Collaborator

d-e-s-o commented Jul 21, 2023

With df959af we have a custom error type that allows for additional context to be provided by the library (e.g., on top of system errors such as ENOENT). We should make use of this capability to improve the quality of error messages in general. Basically, when there is a reason to believe that a low-level error is not particularly useful without context, add some via ErrorExt::context or ErrorExt::with_context. Here is an example:

let dw_unit = sections.unit(header).with_context(|| {
format!(
"failed to retrieve DWARF unit for unit header @ {}",
format_offset(header.offset())
)
})?;

On this path it would probably make sense to add further context higher up the stack so that users know exactly which DWARF file the error occurred on.

Among other things, doing so could help with error reports such as:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error: No such file or directory (os error 2)', benches/symbolize.rs:70:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This task is a good opportunity to become familiar with the code base and it can be done in stages (every improvement helps).

@d-e-s-o d-e-s-o added help wanted Extra attention is needed good first issue Good for newcomers labels Jul 21, 2023
danielocfb pushed a commit that referenced this issue Jul 25, 2023
Annotate a few error paths with additional information that can be
useful in understanding failures.

Refs: #266

Signed-off-by: Daniel Müller <deso@posteo.net>
d-e-s-o added a commit to d-e-s-o/blazesym that referenced this issue Dec 2, 2023
This change adds context to two more error paths in an attempt to
improve error reporting.

Refs: libbpf#266

Signed-off-by: Daniel Müller <deso@posteo.net>
d-e-s-o added a commit to d-e-s-o/blazesym that referenced this issue Dec 4, 2023
This change adds context to two more error paths in an attempt to
improve error reporting.

Refs: libbpf#266

Signed-off-by: Daniel Müller <deso@posteo.net>
danielocfb pushed a commit that referenced this issue Dec 4, 2023
This change adds context to two more error paths in an attempt to
improve error reporting.

Refs: #266

Signed-off-by: Daniel Müller <deso@posteo.net>
@danielocfb
Copy link
Collaborator

I added some more context over time, whenever I felt it was not sufficient. Probably does no longer make sense to have a dedicated task open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants