Remove ErrorError
This commit is contained in:
parent
a43bfd8f63
commit
70f05ac068
|
@ -22,11 +22,6 @@ pub enum Error {
|
||||||
/// Among other things, this includes invoking operators on wrong types (such as calling or
|
/// Among other things, this includes invoking operators on wrong types (such as calling or
|
||||||
/// indexing a `nil` value).
|
/// indexing a `nil` value).
|
||||||
RuntimeError(String),
|
RuntimeError(String),
|
||||||
/// Lua error from inside an error handler, aka `LUA_ERRERR`.
|
|
||||||
///
|
|
||||||
/// To prevent an infinite recursion when invoking an error handler, this error will be returned
|
|
||||||
/// instead of invoking the error handler.
|
|
||||||
ErrorError(String),
|
|
||||||
/// A Rust value could not be converted to a Lua value.
|
/// A Rust value could not be converted to a Lua value.
|
||||||
ToLuaConversionError {
|
ToLuaConversionError {
|
||||||
/// Name of the Rust type that could not be converted.
|
/// Name of the Rust type that could not be converted.
|
||||||
|
@ -108,7 +103,6 @@ impl fmt::Display for Error {
|
||||||
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, "runtime error: {}", 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 } => {
|
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 {
|
||||||
|
@ -138,7 +132,6 @@ impl StdError for Error {
|
||||||
match *self {
|
match *self {
|
||||||
Error::SyntaxError { .. } => "syntax error",
|
Error::SyntaxError { .. } => "syntax error",
|
||||||
Error::RuntimeError(_) => "runtime error",
|
Error::RuntimeError(_) => "runtime 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 => "attempt to resume inactive coroutine",
|
Error::CoroutineInactive => "attempt to resume inactive coroutine",
|
||||||
|
|
|
@ -287,7 +287,12 @@ pub unsafe fn handle_error(state: *mut ffi::lua_State, err: c_int) -> Result<()>
|
||||||
message: err_string,
|
message: err_string,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ffi::LUA_ERRERR => Error::ErrorError(err_string),
|
ffi::LUA_ERRERR => {
|
||||||
|
// This can only happen when rlua's own message handler raises an error, which
|
||||||
|
// should never happen unless there's a bug. This would also be dangerous as it
|
||||||
|
// longjmps over Rust frames.
|
||||||
|
lua_panic!(state, "message handler raised error: {}", err_string);
|
||||||
|
}
|
||||||
ffi::LUA_ERRMEM => {
|
ffi::LUA_ERRMEM => {
|
||||||
// This is not impossible to hit, but this library is not set up
|
// This is not impossible to hit, but this library is not set up
|
||||||
// to handle this properly. Lua does a longjmp on out of memory
|
// to handle this properly. Lua does a longjmp on out of memory
|
||||||
|
|
Loading…
Reference in New Issue