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.
This commit is contained in:
parent
bf76e41487
commit
38a13c906e
24
src/error.rs
24
src/error.rs
|
@ -112,8 +112,8 @@ impl fmt::Display for Error {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
Error::SyntaxError { ref message, .. } => write!(fmt, "syntax error: {}", message),
|
Error::SyntaxError { ref message, .. } => write!(fmt, "syntax error: {}", message),
|
||||||
Error::RuntimeError(ref msg) => write!(fmt, "Lua runtime error: {}", msg),
|
Error::RuntimeError(ref msg) => write!(fmt, "runtime error: {}", msg),
|
||||||
Error::ErrorError(ref msg) => write!(fmt, "Lua error in error handler: {}", msg),
|
Error::ErrorError(ref msg) => write!(fmt, "error in error handler: {}", msg),
|
||||||
Error::ToLuaConversionError { from, to, ref message } => {
|
Error::ToLuaConversionError { from, to, ref message } => {
|
||||||
write!(fmt, "error converting {} to Lua {}", from, to)?;
|
write!(fmt, "error converting {} to Lua {}", from, to)?;
|
||||||
match *message {
|
match *message {
|
||||||
|
@ -131,10 +131,10 @@ impl fmt::Display for Error {
|
||||||
write!(fmt, " ({}; expected {})", message, expected),
|
write!(fmt, " ({}; expected {})", message, expected),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Error::CoroutineInactive => write!(fmt, "Cannot resume inactive coroutine"),
|
Error::CoroutineInactive => write!(fmt, "cannot resume inactive coroutine"),
|
||||||
Error::UserDataTypeMismatch => write!(fmt, "Userdata not expected type"),
|
Error::UserDataTypeMismatch => write!(fmt, "userdata is not expected type"),
|
||||||
Error::UserDataBorrowError => write!(fmt, "Userdata already mutably borrowed"),
|
Error::UserDataBorrowError => write!(fmt, "userdata already mutably borrowed"),
|
||||||
Error::UserDataBorrowMutError => write!(fmt, "Userdata already borrowed"),
|
Error::UserDataBorrowMutError => write!(fmt, "userdata already borrowed"),
|
||||||
Error::CallbackError { ref cause, .. } => write!(fmt, "{}", cause),
|
Error::CallbackError { ref cause, .. } => write!(fmt, "{}", cause),
|
||||||
Error::ExternalError(ref err) => err.fmt(fmt),
|
Error::ExternalError(ref err) => err.fmt(fmt),
|
||||||
}
|
}
|
||||||
|
@ -145,14 +145,14 @@ impl StdError for Error {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
Error::SyntaxError { .. } => "syntax error",
|
Error::SyntaxError { .. } => "syntax error",
|
||||||
Error::RuntimeError(_) => "lua runtime error",
|
Error::RuntimeError(_) => "runtime error",
|
||||||
Error::ErrorError(_) => "lua error handling error",
|
Error::ErrorError(_) => "error inside error handler",
|
||||||
Error::ToLuaConversionError { .. } => "conversion error to lua",
|
Error::ToLuaConversionError { .. } => "conversion error to lua",
|
||||||
Error::FromLuaConversionError { .. } => "conversion error from lua",
|
Error::FromLuaConversionError { .. } => "conversion error from lua",
|
||||||
Error::CoroutineInactive => "lua coroutine inactive",
|
Error::CoroutineInactive => "attempt to resume inactive coroutine",
|
||||||
Error::UserDataTypeMismatch => "lua userdata type mismatch",
|
Error::UserDataTypeMismatch => "userdata type mismatch",
|
||||||
Error::UserDataBorrowError => "lua userdata already mutably borrowed",
|
Error::UserDataBorrowError => "userdata already mutably borrowed",
|
||||||
Error::UserDataBorrowMutError => "lua userdata already borrowed",
|
Error::UserDataBorrowMutError => "userdata already borrowed",
|
||||||
Error::CallbackError { ref cause, .. } => cause.description(),
|
Error::CallbackError { ref cause, .. } => cause.description(),
|
||||||
Error::ExternalError(ref err) => err.description(),
|
Error::ExternalError(ref err) => err.description(),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue