Hasty Briefsbeta

Bilingual

Show HN: Stack Error – ergonomic error handling for Rust

a year ago
  • #Error Handling
  • #Rust
  • #Debugging
  • Stack Error reduces the up-front cost of designing error handling solutions.
  • Goals of Stack Error: ergonomics similar to anyhow, informative error messages, and typed data for runtime handling.
  • Error messages are co-located with error sources, aiding in code documentation.
  • Example usage with macros like `stack_map!` and `stack_err!` to simplify error handling.
  • Error messages include file name and line number for easier debugging.
  • Handling runtime errors with optional error codes, including HTTP and IO error codes.
  • Allows defining custom error types with methods like `std::convert::From`.
  • Compatibility with the Rust ecosystem via `std::error::Error` implementation.
  • Comparison with `anyhow` and `thiserror`, positioning Stack Error as a middle ground.
  • Features like `ErrorStacks` trait, `ErrorCode` enum, and macros for common operations.
  • How to create custom error types using `derive_stack_error` macro.
  • Examples of building errors with file and line info, error codes, and chaining errors for context.