Cherry-pick changes from rlua:
- Make Value::type_name() public - Update CallbackError and ExternalError Display impl
This commit is contained in:
parent
d8b9c46d28
commit
1a788c48f1
|
@ -184,10 +184,10 @@ impl fmt::Display for Error {
|
||||||
Error::MismatchedRegistryKey => {
|
Error::MismatchedRegistryKey => {
|
||||||
write!(fmt, "RegistryKey used from different Lua state")
|
write!(fmt, "RegistryKey used from different Lua state")
|
||||||
}
|
}
|
||||||
Error::CallbackError { ref traceback, ref cause } => {
|
Error::CallbackError { ref traceback, .. } => {
|
||||||
write!(fmt, "callback error: {}: {}", cause, traceback)
|
write!(fmt, "callback error: {}", traceback)
|
||||||
}
|
}
|
||||||
Error::ExternalError(ref err) => write!(fmt, "external error: {}", err),
|
Error::ExternalError(ref err) => write!(fmt, "{}", err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ impl StdError for Error {
|
||||||
fn source(&self) -> Option<&(dyn StdError + 'static)> {
|
fn source(&self) -> Option<&(dyn StdError + 'static)> {
|
||||||
match *self {
|
match *self {
|
||||||
Error::CallbackError { ref cause, .. } => Some(cause.as_ref()),
|
Error::CallbackError { ref cause, .. } => Some(cause.as_ref()),
|
||||||
Error::ExternalError(ref err) => Some(err.as_ref()),
|
Error::ExternalError(ref err) => err.source(),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,18 +48,19 @@ pub enum Value<'lua> {
|
||||||
pub use self::Value::Nil;
|
pub use self::Value::Nil;
|
||||||
|
|
||||||
impl<'lua> Value<'lua> {
|
impl<'lua> Value<'lua> {
|
||||||
pub(crate) fn type_name(&self) -> &'static str {
|
pub fn type_name(&self) -> &'static str {
|
||||||
match *self {
|
match *self {
|
||||||
Value::Nil => "nil",
|
Value::Nil => "nil",
|
||||||
Value::Boolean(_) => "boolean",
|
Value::Boolean(_) => "boolean",
|
||||||
Value::LightUserData(_) => "light userdata",
|
Value::LightUserData(_) => "lightuserdata",
|
||||||
Value::Integer(_) => "integer",
|
Value::Integer(_) => "integer",
|
||||||
Value::Number(_) => "number",
|
Value::Number(_) => "number",
|
||||||
Value::String(_) => "string",
|
Value::String(_) => "string",
|
||||||
Value::Table(_) => "table",
|
Value::Table(_) => "table",
|
||||||
Value::Function(_) => "function",
|
Value::Function(_) => "function",
|
||||||
Value::Thread(_) => "thread",
|
Value::Thread(_) => "thread",
|
||||||
Value::UserData(_) | Value::Error(_) => "userdata",
|
Value::UserData(_) => "userdata",
|
||||||
|
Value::Error(_) => "error",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue