#error #result #fatal #rich #recoverable #handle

nightly no-std rich-result

Rich result type differentiating between recoverable & fatal errors

2 releases

0.1.2 Dec 22, 2022
0.1.1 Dec 22, 2022
0.1.0 Nov 29, 2022

#1857 in Rust patterns

Download history 16/week @ 2024-02-22 38/week @ 2024-02-29 7/week @ 2024-03-07

51 downloads per month

CC0 license

31KB
861 lines

A richer Result type for Rust

(on crates.io)

Defined as

pub enum Result<T, RE, FE> {
    Ok(T),
    Recoverable(RE),
    Fatal(FE),
}

it can handle recoverable & fatal errors somewhat easily.

Using ? on it, it either diverges with Result::Fatal for a Result::Fatal, or returns a

pub enum LocalResult<T, RE> {
    NoErr(T),
    Handle(RE),
}

which in turn can be used with ? to get the T out of it, or diverge with a Result::Recoverable.

Result from core when used with ? either diverges with Fatal or returns the value in Ok.

Additionally, for a public API surface for example, you can use the Result type from core by stacking it like so: Result<Result<T, RE>, FE>, with all the instances of ? working as expected.

No runtime deps

Features