diff options
Diffstat (limited to 'mingling_core/src/program/exec')
| -rw-r--r-- | mingling_core/src/program/exec/error.rs | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/mingling_core/src/program/exec/error.rs b/mingling_core/src/program/exec/error.rs index 944e89a..c8cb15a 100644 --- a/mingling_core/src/program/exec/error.rs +++ b/mingling_core/src/program/exec/error.rs @@ -24,12 +24,12 @@ pub enum ProgramExecuteError { impl fmt::Display for ProgramExecuteError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - ProgramExecuteError::DispatcherNotFound => write!(f, "No Dispatcher Found"), - ProgramExecuteError::RendererNotFound(s) => { + Self::DispatcherNotFound => write!(f, "No Dispatcher Found"), + Self::RendererNotFound(s) => { write!(f, "No Renderer (`{s}`) Found") } - ProgramExecuteError::Panic(p) => write!(f, "Panic: {p:?}"), - ProgramExecuteError::Other(s) => write!(f, "Other error: {s}"), + Self::Panic(p) => write!(f, "Panic: {p:?}"), + Self::Other(s) => write!(f, "Other error: {s}"), } } } @@ -38,7 +38,7 @@ impl std::error::Error for ProgramExecuteError {} impl From<ProgramPanic> for ProgramExecuteError { fn from(value: ProgramPanic) -> Self { - ProgramExecuteError::Panic(value) + Self::Panic(value) } } @@ -70,17 +70,11 @@ pub enum ProgramInternalExecuteError { impl fmt::Display for ProgramInternalExecuteError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - ProgramInternalExecuteError::DispatcherNotFound => { - write!(f, "No Dispatcher Found") - } - ProgramInternalExecuteError::RendererNotFound(s) => { - write!(f, "No Renderer (`{s}`) Found") - } - ProgramInternalExecuteError::Other(s) => write!(f, "Other error: {s}"), - ProgramInternalExecuteError::IO(e) => write!(f, "IO error: {e}"), - ProgramInternalExecuteError::REPLPanic(panic) => { - write!(f, "A single REPL execution failed: {panic}") - } + Self::DispatcherNotFound => write!(f, "No Dispatcher Found"), + Self::RendererNotFound(s) => write!(f, "No Renderer (`{s}`) Found"), + Self::Other(s) => write!(f, "Other error: {s}"), + Self::IO(e) => write!(f, "IO error: {e}"), + Self::REPLPanic(panic) => write!(f, "A single REPL execution failed: {panic}"), } } } @@ -88,7 +82,7 @@ impl fmt::Display for ProgramInternalExecuteError { impl std::error::Error for ProgramInternalExecuteError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { - ProgramInternalExecuteError::IO(e) => Some(e), + Self::IO(e) => Some(e), _ => None, } } @@ -96,23 +90,19 @@ impl std::error::Error for ProgramInternalExecuteError { impl From<std::io::Error> for ProgramInternalExecuteError { fn from(e: std::io::Error) -> Self { - ProgramInternalExecuteError::IO(e) + Self::IO(e) } } impl From<ProgramInternalExecuteError> for ProgramExecuteError { fn from(value: ProgramInternalExecuteError) -> Self { match value { - ProgramInternalExecuteError::DispatcherNotFound => { - ProgramExecuteError::DispatcherNotFound - } - ProgramInternalExecuteError::RendererNotFound(s) => { - ProgramExecuteError::RendererNotFound(s) - } - ProgramInternalExecuteError::Other(s) => ProgramExecuteError::Other(s), - ProgramInternalExecuteError::IO(e) => ProgramExecuteError::Other(format!("{e}")), + ProgramInternalExecuteError::DispatcherNotFound => Self::DispatcherNotFound, + ProgramInternalExecuteError::RendererNotFound(s) => Self::RendererNotFound(s), + ProgramInternalExecuteError::Other(s) => Self::Other(s), + ProgramInternalExecuteError::IO(e) => Self::Other(format!("{e}")), ProgramInternalExecuteError::REPLPanic(p) => { - ProgramExecuteError::Other(format!("A single REPL execution failed: {p}")) + Self::Other(format!("A single REPL execution failed: {p}")) } } } @@ -121,8 +111,8 @@ impl From<ProgramInternalExecuteError> for ProgramExecuteError { impl From<ChainProcessError> for ProgramInternalExecuteError { fn from(value: ChainProcessError) -> Self { match value { - ChainProcessError::Other(s) => ProgramInternalExecuteError::Other(s), - ChainProcessError::IO(error) => ProgramInternalExecuteError::IO(error), + ChainProcessError::Other(s) => Self::Other(s), + ChainProcessError::IO(error) => Self::IO(error), } } } |
