datex_core/runtime/execution/context/
script.rs1#[cfg(feature = "compiler")]
2use crate::compiler::error::SpannedCompilerError;
3use crate::{prelude::*, runtime::execution::ExecutionError};
4use core::fmt::Display;
5#[derive(Debug)]
6pub enum ScriptExecutionError {
7 #[cfg(feature = "compiler")]
8 CompilerError(Box<SpannedCompilerError>),
9 ExecutionError(Box<ExecutionError>),
10}
11
12#[cfg(feature = "compiler")]
13impl From<SpannedCompilerError> for ScriptExecutionError {
14 fn from(err: SpannedCompilerError) -> Self {
15 ScriptExecutionError::CompilerError(Box::new(err))
16 }
17}
18
19impl From<ExecutionError> for ScriptExecutionError {
20 fn from(err: ExecutionError) -> Self {
21 ScriptExecutionError::ExecutionError(Box::new(err))
22 }
23}
24
25impl Display for ScriptExecutionError {
26 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
27 match self {
28 #[cfg(feature = "compiler")]
29 ScriptExecutionError::CompilerError(err) => {
30 core::write!(f, "Compiler Error: {}", err)
31 }
32 ScriptExecutionError::ExecutionError(err) => {
33 core::write!(f, "Execution Error: {}", err)
34 }
35 }
36 }
37}