arkworks-rs / snark

Interfaces for Relations and SNARKs for these relations
https://www.arkworks.rs
Apache License 2.0
776 stars 209 forks source link

Augment error handling with location information. #249

Open Pratyush opened 4 years ago

Pratyush commented 4 years ago

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().