Update Error doc

This commit is contained in:
Alex Orlenko 2023-03-26 20:58:43 +01:00
parent d9aac08b81
commit cd9fc1d08f
No known key found for this signature in database
GPG Key ID: 4C150C250863B96D
1 changed files with 9 additions and 0 deletions

View File

@ -156,8 +156,11 @@ pub enum Error {
///
/// [`MetaMethod`]: crate::MetaMethod
MetaMethodTypeError {
/// Name of the metamethod.
method: StdString,
/// Passed value type.
type_name: &'static str,
/// A string containing more detailed error information.
message: Option<StdString>,
},
/// A [`RegistryKey`] produced from a different Lua state was used.
@ -194,7 +197,9 @@ pub enum Error {
ExternalError(Arc<dyn StdError + Send + Sync>),
/// An error with additional context.
WithContext {
/// A string containing additional context.
context: StdString,
/// Underlying error.
cause: Arc<Error>,
},
}
@ -399,7 +404,11 @@ where
/// Provides the `context` method for [`Error`] and `Result<T, Error>`.
pub trait ErrorContext: Sealed {
/// Wraps the error value with additional context.
fn context<C: fmt::Display>(self, context: C) -> Self;
/// Wrap the error value with additional context that is evaluated lazily
/// only once an error does occur.
fn with_context<C: fmt::Display>(self, f: impl FnOnce(&Error) -> C) -> Self;
}