Fix panic of continue/break/return in try-catch block.

This commit is contained in:
Stephen Chung
2021-02-09 14:22:21 +08:00
parent e88e65f36e
commit 2dd5aceb1d
2 changed files with 21 additions and 5 deletions

View File

@@ -272,6 +272,15 @@ impl<T: AsRef<str>> From<T> for Box<EvalAltResult> {
}
impl EvalAltResult {
/// Is this a pseudo error? A pseudo error is one that does not occur naturally.
///
/// [`LoopBreak`][EvalAltResult::LoopBreak] or [`Return`][EvalAltResult::Return] are pseudo errors.
pub fn is_pseudo_error(&self) -> bool {
match self {
Self::LoopBreak(_, _) | Self::Return(_, _) => true,
_ => false,
}
}
/// Can this error be caught?
///
/// # Panics