Skip to content

Commit 0061fed

Browse files
florianhartungwucke13
authored andcommitted
feat: implement core::error::Error for all errors
Signed-off-by: Florian Hartung <florian.hartung@dlr.de>
1 parent e06cb5e commit 0061fed

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/core/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ pub enum ValidationError {
142142
ActiveElementSegmentTypeMismatch,
143143
}
144144

145+
impl core::error::Error for ValidationError {}
146+
145147
impl Display for ValidationError {
146148
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
147149
match self {

src/execution/error.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ impl Display for RuntimeError {
3939
}
4040
}
4141

42+
impl core::error::Error for RuntimeError {
43+
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
44+
match self {
45+
RuntimeError::Trap(trap_err) => Some(trap_err),
46+
_ => None,
47+
}
48+
}
49+
}
50+
4251
#[derive(Debug, PartialEq, Eq, Clone)]
4352
pub enum TrapError {
4453
DivideBy0,
@@ -90,6 +99,8 @@ impl Display for TrapError {
9099
}
91100
}
92101

102+
impl core::error::Error for TrapError {}
103+
93104
impl From<TrapError> for RuntimeError {
94105
fn from(value: TrapError) -> Self {
95106
Self::Trap(value)

0 commit comments

Comments
 (0)