Rename `error` to `cause` in `Error::BadArgument`

This commit is contained in:
Alex Orlenko 2023-03-16 23:48:54 +00:00
parent 03787668fd
commit a0d37fd182
No known key found for this signature in database
GPG Key ID: 4C150C250863B96D
2 changed files with 6 additions and 6 deletions

View File

@ -81,7 +81,7 @@ pub enum Error {
/// Argument name. /// Argument name.
name: Option<StdString>, name: Option<StdString>,
/// Underlying error returned when converting argument to a Lua value. /// Underlying error returned when converting argument to a Lua value.
error: Arc<Error>, cause: Arc<Error>,
}, },
/// A Rust value could not be converted to a Lua value. /// A Rust value could not be converted to a Lua value.
ToLuaConversionError { ToLuaConversionError {
@ -230,7 +230,7 @@ impl fmt::Display for Error {
fmt, fmt,
"too many arguments to Function::bind" "too many arguments to Function::bind"
), ),
Error::BadArgument { ref to, pos, ref name, ref error } => { Error::BadArgument { ref to, pos, ref name, ref cause } => {
if let Some(name) = name { if let Some(name) = name {
write!(fmt, "bad argument `{name}`")?; write!(fmt, "bad argument `{name}`")?;
} else { } else {
@ -239,7 +239,7 @@ impl fmt::Display for Error {
if let Some(to) = to { if let Some(to) = to {
write!(fmt, " to `{to}`")?; write!(fmt, " to `{to}`")?;
} }
write!(fmt, ": {error}") write!(fmt, ": {cause}")
}, },
Error::ToLuaConversionError { from, to, ref message } => { Error::ToLuaConversionError { from, to, ref message } => {
write!(fmt, "error converting {from} to Lua {to}")?; write!(fmt, "error converting {from} to Lua {to}")?;
@ -329,12 +329,12 @@ impl Error {
Error::ExternalError(err.into().into()) Error::ExternalError(err.into().into())
} }
pub(crate) fn bad_self_argument(to: &str, error: Error) -> Self { pub(crate) fn bad_self_argument(to: &str, cause: Error) -> Self {
Error::BadArgument { Error::BadArgument {
to: Some(to.to_string()), to: Some(to.to_string()),
pos: 1, pos: 1,
name: Some("self".to_string()), name: Some("self".to_string()),
error: Arc::new(error), cause: Arc::new(cause),
} }
} }

View File

@ -205,7 +205,7 @@ pub trait FromLua<'lua>: Sized {
to: to.map(|s| s.to_string()), to: to.map(|s| s.to_string()),
pos: i, pos: i,
name: None, name: None,
error: Arc::new(err), cause: Arc::new(err),
}) })
} }
} }