Skip to content

BusyJay/rust-throw

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Throw!

Throw is a new experimental rust error handling library, meant to assist and build on existing error handling systems.

Throw exports two structs, throw::ErrorPoint and throw::Error. throw::Error stores a single original_error variable which it is created from, and then a list of ErrorPoints which starts out with the original point of creation with throw!(), and is added to every time you propagate the error upwards with up!().

Throw does not replace existing error handling systems. The throw::Error type has a type parameter E which represents an internal error type stored. throw::Error just wraps your error type and stores ErrorPoints alongside it.

Throw helps you better keep track of your errors. Instead of seeing a generic "No such file or directory" message, you get a stack trace of functions which propagated the error as well.

Instead of:

IO Error: failed to lookup address information: Name or service not known

Get:

Error: IO Error: failed to lookup address information: Name or service not known
    at 79:17 in zaldinar::startup (src/startup.rs)
    at 104:4 in zaldinar::startup (src/startup.rs)
    at 28:17 in zaldinar_irclib (/home/daboross/Projects/Rust/zaldinar/zaldinar-irclib/src/lib.rs)

About

Rust error handling with stack traces!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%