Show HN: Stack Error – ergonomic error handling for Rust
Published on: 2025-07-04 10:46:02
Stack Error
Stack Error reduces the up-front cost of designing an error handling solution for your project, so that you focus on writing great libraries and applications. Stack Error has three goals:
Provide ergonomics similar to anyhow . Create informative error messages that facilitate debugging. Provide typed data that facilitates runtime error handling.
Overview
Build informative error messages for debugging with minimal effort. The error message is co-located with the error source, which helps document your code. use stackerror :: prelude :: * ; pub fn process_data ( data : & str ) -> StackResult < String > { let data : Vec < String > = serde_json :: from_str ( data ) . map_err ( stack_map ! ( StackError , "data is not a list of strings" ) ) ? ; data . first ( ) . cloned ( ) . ok_or_else ( stack_else ! ( StackError , "data is empty" ) ) } In this example, [ stack_map! ] and [ stack_err! ] build a new instance of [ StackError ], adding file name and line number information to t
... Read full article.