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 context tracking for errors #18

Merged
merged 6 commits into from
Nov 11, 2024
Merged

Add context tracking for errors #18

merged 6 commits into from
Nov 11, 2024

Conversation

bal-e
Copy link
Contributor

@bal-e bal-e commented Nov 6, 2024

This enhances the Error type to store a "context stack", a way to tell where in a program the specific error occurred. For example, when parsing a zone file, context may be used to inform the user about the line number of a parse error. An extension trait for Result has also been introduced that eliminates the need for .map_err() to add context.

@bal-e bal-e self-assigned this Nov 6, 2024
@tertsdiepraam tertsdiepraam self-requested a review November 6, 2024 14:22
@bal-e
Copy link
Contributor Author

bal-e commented Nov 6, 2024

Hang on, I'm adding a .context() and .with_context() method to Result.

src/error.rs Outdated Show resolved Hide resolved
src/error.rs Show resolved Hide resolved
src/error.rs Show resolved Hide resolved
src/error.rs Outdated
struct Information {
/// The primary error message.
///
/// This is the innermost error to occur.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit strangely worded I think. There's only one error, so there's no innermost.

@bal-e bal-e merged commit 8dc82c7 into main Nov 11, 2024
29 checks passed
@bal-e bal-e deleted the error-context branch November 11, 2024 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants