print errors better

This commit is contained in:
Quaternions 2024-10-03 18:54:37 -07:00
parent 5a1df16bd9
commit 6c12bc2bf6

View File

@ -16,8 +16,8 @@ pub enum Error{
impl std::fmt::Display for Error{ impl std::fmt::Display for Error{
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{ fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
match self{ match self{
Self::Lua{source,error:mlua::Error::RuntimeError(s)}=>write!(f,"lua error: {s}\nsource:{source}"), Self::Lua{source,error}=>write!(f,"lua error: source:\n{source}\n{error}"),
Self::RustLua(mlua::Error::RuntimeError(s))=>write!(f,"rust-side lua error: {s}"), Self::RustLua(error)=>write!(f,"rust-side lua error: {error}"),
other=>write!(f,"{other:?}"), other=>write!(f,"{other:?}"),
} }
} }