Skip to content

Commit cd445d5

Browse files
feat: implement core::error::Error for all errors
Signed-off-by: Florian Hartung <florian.hartung@dlr.de>
1 parent 4b1300f commit cd445d5

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
@@ -146,6 +146,8 @@ pub enum ValidationError {
146146
I33IsNegative,
147147
}
148148

149+
impl core::error::Error for ValidationError {}
150+
149151
impl Display for ValidationError {
150152
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
151153
match self {

src/execution/error.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ impl Display for RuntimeError {
109109
}
110110
}
111111

112+
impl core::error::Error for RuntimeError {
113+
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
114+
match self {
115+
RuntimeError::Trap(trap_err) => Some(trap_err),
116+
_ => None,
117+
}
118+
}
119+
}
120+
112121
#[derive(Debug, PartialEq, Eq, Clone)]
113122
pub enum TrapError {
114123
DivideBy0,
@@ -160,6 +169,8 @@ impl Display for TrapError {
160169
}
161170
}
162171

172+
impl core::error::Error for TrapError {}
173+
163174
impl From<TrapError> for RuntimeError {
164175
fn from(value: TrapError) -> Self {
165176
Self::Trap(value)

0 commit comments

Comments
 (0)