From 38a13c906ee7d0a9cb05cf1d164ad17b79447758 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 1 Aug 2017 23:22:07 +0200 Subject: [PATCH] Remove "lua" prefix from error messages Since this is `rlua::Error`, it should be clear that it refers to Lua-related errors. Downstream crates want to define their own error enums, which can add a prefix like "lua error:" to disambiguate. --- src/error.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/error.rs b/src/error.rs index f56223f..1509651 100644 --- a/src/error.rs +++ b/src/error.rs @@ -112,8 +112,8 @@ impl fmt::Display for Error { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match *self { Error::SyntaxError { ref message, .. } => write!(fmt, "syntax error: {}", message), - Error::RuntimeError(ref msg) => write!(fmt, "Lua runtime error: {}", msg), - Error::ErrorError(ref msg) => write!(fmt, "Lua error in error handler: {}", msg), + Error::RuntimeError(ref msg) => write!(fmt, "runtime error: {}", msg), + Error::ErrorError(ref msg) => write!(fmt, "error in error handler: {}", msg), Error::ToLuaConversionError { from, to, ref message } => { write!(fmt, "error converting {} to Lua {}", from, to)?; match *message { @@ -131,10 +131,10 @@ impl fmt::Display for Error { write!(fmt, " ({}; expected {})", message, expected), } } - Error::CoroutineInactive => write!(fmt, "Cannot resume inactive coroutine"), - Error::UserDataTypeMismatch => write!(fmt, "Userdata not expected type"), - Error::UserDataBorrowError => write!(fmt, "Userdata already mutably borrowed"), - Error::UserDataBorrowMutError => write!(fmt, "Userdata already borrowed"), + Error::CoroutineInactive => write!(fmt, "cannot resume inactive coroutine"), + Error::UserDataTypeMismatch => write!(fmt, "userdata is not expected type"), + Error::UserDataBorrowError => write!(fmt, "userdata already mutably borrowed"), + Error::UserDataBorrowMutError => write!(fmt, "userdata already borrowed"), Error::CallbackError { ref cause, .. } => write!(fmt, "{}", cause), Error::ExternalError(ref err) => err.fmt(fmt), } @@ -145,14 +145,14 @@ impl StdError for Error { fn description(&self) -> &str { match *self { Error::SyntaxError { .. } => "syntax error", - Error::RuntimeError(_) => "lua runtime error", - Error::ErrorError(_) => "lua error handling error", + Error::RuntimeError(_) => "runtime error", + Error::ErrorError(_) => "error inside error handler", Error::ToLuaConversionError { .. } => "conversion error to lua", Error::FromLuaConversionError { .. } => "conversion error from lua", - Error::CoroutineInactive => "lua coroutine inactive", - Error::UserDataTypeMismatch => "lua userdata type mismatch", - Error::UserDataBorrowError => "lua userdata already mutably borrowed", - Error::UserDataBorrowMutError => "lua userdata already borrowed", + Error::CoroutineInactive => "attempt to resume inactive coroutine", + Error::UserDataTypeMismatch => "userdata type mismatch", + Error::UserDataBorrowError => "userdata already mutably borrowed", + Error::UserDataBorrowMutError => "userdata already borrowed", Error::CallbackError { ref cause, .. } => cause.description(), Error::ExternalError(ref err) => err.description(), }