Unwrap error when caught.

This commit is contained in:
Stephen Chung
2022-02-08 19:02:40 +08:00
parent 7686ca619a
commit 83b213b086
4 changed files with 25 additions and 4 deletions

View File

@@ -403,6 +403,16 @@ impl EvalAltResult {
}
};
}
/// Unwrap this error and get the very base error.
#[must_use]
pub fn unwrap_inner(&self) -> &Self {
match self {
Self::ErrorInFunctionCall(.., err, _) | Self::ErrorInModule(.., err, _) => {
err.unwrap_inner()
}
_ => self,
}
}
/// Get the [position][Position] of this error.
#[must_use]
pub const fn position(&self) -> Position {