Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mitsuhiko/rust-incidents
Even more error handling experiments in Rust.
https://github.com/mitsuhiko/rust-incidents
Last synced: 3 months ago
JSON representation
Even more error handling experiments in Rust.
- Host: GitHub
- URL: https://github.com/mitsuhiko/rust-incidents
- Owner: mitsuhiko
- License: other
- Created: 2014-11-20T15:08:03.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-19T13:25:48.000Z (over 9 years ago)
- Last Synced: 2024-05-08T21:52:56.378Z (8 months ago)
- Language: Rust
- Homepage: http://mitsuhiko.github.io/rust-incidents/
- Size: 939 KB
- Stars: 17
- Watchers: 2
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rust-incidents
This library provides an experiment for error handling in Rust.
It provides efficient error handling and provides powerful debugging
features.- keeps results small by providing a de-refable failure type
- provides support for python-style tracebacks in debug builds
- allows errors to be freely convertible between each other through
the `FromError` trait.
- provides a flexible trait for error interoperability.```rust
struct BadOperation {
desc: &str,
}impl Error for BadOperation {
fn name(&self) -> &str { "Bad Operation" }
fn description(&self) -> Option<&str> { Some(self.desc) }
}fn something_that_fails(good: bool) -> FResult {
if !good {
fail!(BadOperation { desc: "Something wend badly wrong" });
}
Ok(42)
}fn function_that_tries() -> FResult {
let rv = try!(function_that_fails());
Ok(rv + 42)
}
```