diff --git a/src/lune/error.rs b/src/lune/error.rs index dcb9222..1999877 100644 --- a/src/lune/error.rs +++ b/src/lune/error.rs @@ -62,6 +62,15 @@ impl From for LuneError { } } +impl From<&LuaError> for LuneError { + fn from(value: &LuaError) -> Self { + Self { + error: value.clone(), + disable_colors: false, + } + } +} + impl Display for LuneError { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { write!(f, "{}", self.error) // TODO: Pretty formatting diff --git a/src/lune/scheduler/impl_runner.rs b/src/lune/scheduler/impl_runner.rs index 82617cf..0ed44a8 100644 --- a/src/lune/scheduler/impl_runner.rs +++ b/src/lune/scheduler/impl_runner.rs @@ -5,6 +5,8 @@ use mlua::prelude::*; use tokio::task::LocalSet; +use crate::LuneError; + use super::Scheduler; impl<'lua, 'fut> Scheduler<'lua, 'fut> @@ -43,10 +45,10 @@ where // If we got any resumption (lua-side) error, increment // the error count of the scheduler so we can exit with // a non-zero exit code, and print it out to stderr - // TODO: Pretty print the lua error here if let Err(err) = &res { self.state.increment_error_count(); - eprint!("{err}"); + // NOTE: LuneError will pretty-format this error + eprint!("{}", LuneError::from(err)); } // Send results of resuming this thread to any listeners