pub trait ForgeError:
Error
+ Send
+ Sync
+ 'static {
// Required methods
fn kind(&self) -> &'static str;
fn caption(&self) -> &'static str;
// Provided methods
fn is_retryable(&self) -> bool { ... }
fn is_fatal(&self) -> bool { ... }
fn status_code(&self) -> u16 { ... }
fn exit_code(&self) -> i32 { ... }
fn user_message(&self) -> String { ... }
fn dev_message(&self) -> String { ... }
fn backtrace(&self) -> Option<&Backtrace> { ... }
fn register(&self) { ... }
}Expand description
Base trait for all custom error variants.
Required Methods§
Provided Methods§
Sourcefn is_retryable(&self) -> bool
fn is_retryable(&self) -> bool
Returns true if the operation can be retried
Sourcefn status_code(&self) -> u16
fn status_code(&self) -> u16
Returns an appropriate HTTP status code for the error
Sourcefn user_message(&self) -> String
fn user_message(&self) -> String
Returns a user-facing message that can be shown to end users
Sourcefn dev_message(&self) -> String
fn dev_message(&self) -> String
Returns a detailed technical message for developers/logs
Sourcefn register(&self)
fn register(&self)
Fires the registered error hook (see
try_register_error_hook)
with this error’s caption, kind and flags.
Despite the name, nothing is stored: this does not touch the
error-code ErrorRegistry.
AppError and define_errors! constructors already fire the
hook, so calling register on such an error fires it a second
time. It is a no-op when no hook is registered.
§Example
use error_forge::{AppError, ForgeError};
let error = AppError::config("missing key");
// Reports the error to the hook again, if one is installed.
error.register();Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".