pub struct ErrorSet { /* private fields */ }
Expand description
A set of errors found in a human-readable encoding of a Simplicity program.
Implementations§
Source§impl ErrorSet
impl ErrorSet
Sourcepub fn first_error(&self) -> Option<(Option<Position>, &Error)>
pub fn first_error(&self) -> Option<(Option<Position>, &Error)>
Returns the first (and presumably most important) error in the set, if it is non-empty, along with its position.
Sourcepub fn iter(&self) -> impl Iterator<Item = &Error>
pub fn iter(&self) -> impl Iterator<Item = &Error>
Return an iterator over the errors in the error set.
Sourcepub fn single<P: Into<Position>, E: Into<Error>>(position: P, err: E) -> Self
pub fn single<P: Into<Position>, E: Into<Error>>(position: P, err: E) -> Self
Constructs a new error set with a single error in it.
Sourcepub fn single_no_position<E: Into<Error>>(err: E) -> Self
pub fn single_no_position<E: Into<Error>>(err: E) -> Self
Constructs a new error set with a single error in it.
Sourcepub fn add<P: Into<Position>, E: Into<Error>>(&mut self, position: P, err: E)
pub fn add<P: Into<Position>, E: Into<Error>>(&mut self, position: P, err: E)
Adds an error to the error set.
Sourcepub fn add_no_position<E: Into<Error>>(&mut self, err: E)
pub fn add_no_position<E: Into<Error>>(&mut self, err: E)
Adds an error to the error set.
Sourcepub fn merge(&mut self, other: &Self)
pub fn merge(&mut self, other: &Self)
Merges another set of errors into the current set.
§Panics
Panics if the two sets have different contexts attached.
Sourcepub fn add_context(&mut self, s: Arc<str>)
pub fn add_context(&mut self, s: Arc<str>)
Attaches the input code to the error set, so that error messages can include line numbers etc.
§Panics
Panics if it is called twice on the same error set. You should call this once with the complete input code.
Sourcepub fn into_result<T>(self, ok: T) -> Result<T, Self>
pub fn into_result<T>(self, ok: T) -> Result<T, Self>
Converts the error set into a result.
If the set is empty, returns Ok with the given value. Otherwise returns Err with itself.
Sourcepub fn into_result_with<T, F: FnOnce() -> T>(self, okfn: F) -> Result<T, Self>
pub fn into_result_with<T, F: FnOnce() -> T>(self, okfn: F) -> Result<T, Self>
Converts the error set into a result.
If the set is empty, returns Ok with the result of calling the given closure. Otherwise returns Err with itself.