utils-results
The easiest and most intuitive error handling solution. (no dependencies, about 150 lines pure codes)
| Docs |
[]
= "3.0.0"
Overview
First, You should make your own an error set.
err!
And just errbang!
errbang!
More Examples
errbang!;
errbang!;
errbang!;
errcast
Any type of error can be converted into our Master Error. (non panic unwraping)
<Unwraped Ok> = errcast! (<Any Result>, <Master Err>, <Optional meta,..>);
// example
let num_read = errcast!;
Also casted error has more information.
// example
let file = errcast!;
Error: MyError { meta: "[src/main.rs:8] casted error [ fs::File::open(\"test\") ==> Os { code: 2, kind: NotFound, message: \"No such file or directory\" } ] *also io error", message: "this is my error." }
Simply just do this!
let file = errcast!
or...
// master `Result` can take any errors
let file = open?;
But, errcast -> errextract combo is really good choice.
More idiomatic way to handle io::Error
io_err!
Declare matching macro and just handle that.
io_to_err!?;
err_to_io!?;
Master Result
- Please use our Master Result<T> and ResultSend<T> instead std::result::Result or io::Result etc..
utils-results/lib.rs Definition
/// Master Result
pub type Result<T> = Result;
/// Master Result for Send + Sync trait
pub type ResultSend<T> = Result;
just put this in your project.
pub use *;
You can also convert any type of Result
| easy way
// to our Master Result
resultcast!?;
// also can convert master Result to ResultSend
resultcastsend!?;