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