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

Augment error handling with location information. #249

Open
Pratyush opened this issue Aug 2, 2020 · 0 comments
Open

Augment error handling with location information. #249

Pratyush opened this issue Aug 2, 2020 · 0 comments
Assignees
Labels
D-easy Difficulty: easy T-feature Type: new features

Comments

@Pratyush
Copy link
Member

Pratyush commented Aug 2, 2020

Once 1.46 becomes stable, we should use the #[track_caller] feature to make all errors in this crate more informative following the idea outlined in this playground.

For example, this is how one could modify SynthesisError:

enum ErrorKind {
    AssignmentMissing,
    ...
}

pub struct SynthesisError {
    pub location: &'static Location<'static>,
    pub error: ErrorKind,
}

impl From<ErrorKind> from SynthesisError {
    #[track_caller]
    from(error: ErrorKind>) -> Self {
        let location = caller();
        Self { location, error }
    }
}

This means that we can now track where an error originates, instead of having it show up only when we unwrap().

@Pratyush Pratyush self-assigned this Aug 2, 2020
@Pratyush Pratyush added T-feature Type: new features D-easy Difficulty: easy labels Aug 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D-easy Difficulty: easy T-feature Type: new features
Projects
None yet
Development

No branches or pull requests

1 participant