Registry / utility / custom-error

custom-error

JSON →
library1.9.2rscratesunverified

Define custom errors without boilerplate using the custom_error! macro.

# Cargo.toml [dependencies] custom_error = "1.9.2"
INSTALL
IMPORT
SIG · CUSTOM-ERROR
C
custom-error
utilityrustv1.9.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

custom_error
use custom_error::custom_error;

Defines a custom error enum with Display and Error impls via macro.

use custom_error::custom_error; custom_error! { MyError NotFound{ item: String } = "{item} not found", PermissionDenied = "permission denied", } fn example() -> Result<(), MyError> { Err(MyError::NotFound { item: "file.txt".into() }) } println!("{}", example().unwrap_err());
Debug
Known issues

No known issues recorded.

Upgrade
Version history
1.9.2latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
custom-error — cargo add custom-error · libregistry