Skerry: Super Kool ERRors Yoh
Example:
use *;
// Define your error boundary, there can be only one #[sherry_mod] in your project
// Generates a CheckAuthError enum automatically
>
;
// This allows #[skerry_fn] to run on impl blocks
Core Workflow
- Define all possible error structs in a
#[skerry_mod]. - Mark functions with
#[skerry_fn]. - Use the
*operator to bubble up errors from sub-functions without manually mapping variants.
The Error Module
Every project needs one module (usually errors.rs) that acts as the source of truth.
pub use *; // Recommended to be pub for easier macro expansions
Note: When using errors in any other file, import them via crate::errors::*; instead
of individual imports to ensure the macros can resolve the paths correctly.
Function-Specific Enums
By using #[skerry_fn], you define a return type using a tuple of error structs.
Skerry transforms this into a unique enum named {FunctionName}Error.
>
The Asterisk (*) Expansion
When you put *OtherFnError in your return array it pulls all
variants from OtherFnError into your current function's list.
- Deduplication: Variants are deduplicated automatically. If
ErrAis added manually and also exists inside a*expansion, only one variant is generated.
>
The syntax below has the exact same effects, *LowLevelError is nothing more than syntatic sugar
>
In the cases above the generated enum looks like this
Using Skerry inside Impl Blocks
Skerry provides the #[skerry_impl] attribute to handle methods within impl blocks.
This attribute coordinates with #[skerry_fn] to split the generated code
so error enums are generated outside the impl block.
Example
use *;
#
;
// Optional prefix for functions inside impl block
Using Skerry inside Trait Blocks
Skerry provides the #[skerry_trait] attribute to handle methods within trait blocks.
This attribute coordinates with #[skerry_fn] to split the generated code
so error enums are generated outside the trait block.
Example
use *;
#
// Optional prefix for functions inside trait block
Compile-Time Safety
Skerry uses a custom trait system (MissingConvert) to verify error bounds at
compile-time. If you try to use ? on a function whose errors are not represented
in your current return tuple, the compiler will refuse to build.
License: MIT