Refactor last error (#202)

This commit is contained in:
Mike Voronov
2021-12-28 16:59:55 +03:00
committed by GitHub
parent c1ff7c0688
commit 63160dd0f0
37 changed files with 1386 additions and 1223 deletions

View File

@ -14,8 +14,8 @@
* limitations under the License.
*/
pub(crate) use super::Joinable;
use super::Joinable;
use super::LastErrorAffectable;
use super::Stream;
use crate::execution_step::lambda_applier::LambdaError;
use crate::JValue;
@ -60,15 +60,15 @@ pub enum CatchableError {
/// This error type is produced by a match to notify xor that compared values aren't equal.
#[error("match is used without corresponding xor")]
MatchWithoutXorError,
MatchValuesNotEqual,
/// This error type is produced by a mismatch to notify xor that compared values aren't equal.
#[error("mismatch is used without corresponding xor")]
MismatchWithoutXorError,
MismatchValuesEqual,
/// This error type is produced by a fail instruction.
#[error("fail with ret_code '{ret_code}' and error_message '{error_message}' is used without corresponding xor")]
FailWithoutXorError { ret_code: i64, error_message: String },
#[error("fail with '{error}' is used without corresponding xor")]
UserError { error: Rc<JValue> },
/// An error occurred while trying to apply lambda to a value.
#[error(transparent)]
@ -98,6 +98,15 @@ impl ToErrorCode for CatchableError {
}
}
impl LastErrorAffectable for CatchableError {
fn affects_last_error(&self) -> bool {
!matches!(
self,
CatchableError::MatchValuesNotEqual | CatchableError::MismatchValuesEqual
)
}
}
macro_rules! log_join {
($($args:tt)*) => {
log::info!(target: air_log_targets::JOIN_BEHAVIOUR, $($args)*)