mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Pretty-print lua errors
This commit is contained in:
parent
4acc730d38
commit
b69f824b57
2 changed files with 13 additions and 2 deletions
|
@ -62,6 +62,15 @@ impl From<LuaError> for LuneError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<&LuaError> for LuneError {
|
||||||
|
fn from(value: &LuaError) -> Self {
|
||||||
|
Self {
|
||||||
|
error: value.clone(),
|
||||||
|
disable_colors: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Display for LuneError {
|
impl Display for LuneError {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||||
write!(f, "{}", self.error) // TODO: Pretty formatting
|
write!(f, "{}", self.error) // TODO: Pretty formatting
|
||||||
|
|
|
@ -5,6 +5,8 @@ use mlua::prelude::*;
|
||||||
|
|
||||||
use tokio::task::LocalSet;
|
use tokio::task::LocalSet;
|
||||||
|
|
||||||
|
use crate::LuneError;
|
||||||
|
|
||||||
use super::Scheduler;
|
use super::Scheduler;
|
||||||
|
|
||||||
impl<'lua, 'fut> Scheduler<'lua, 'fut>
|
impl<'lua, 'fut> Scheduler<'lua, 'fut>
|
||||||
|
@ -43,10 +45,10 @@ where
|
||||||
// If we got any resumption (lua-side) error, increment
|
// If we got any resumption (lua-side) error, increment
|
||||||
// the error count of the scheduler so we can exit with
|
// the error count of the scheduler so we can exit with
|
||||||
// a non-zero exit code, and print it out to stderr
|
// a non-zero exit code, and print it out to stderr
|
||||||
// TODO: Pretty print the lua error here
|
|
||||||
if let Err(err) = &res {
|
if let Err(err) = &res {
|
||||||
self.state.increment_error_count();
|
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
|
// Send results of resuming this thread to any listeners
|
||||||
|
|
Loading…
Reference in a new issue