You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Magic_RB d15dfb209e
Add breakage notice
6 months ago
src documented few functions 8 months ago
.gitignore Initial commit 9 months ago
Cargo.toml Cargo.toml: features mimicking std, lib.rs: EResult methods mimicking std 8 months ago
LICENSE Initial commit 9 months ago
README.md Add breakage notice 6 months ago

README.md

E-Error

WARNING Currently broken, because the Try trait is getting reworked or something

E-Error is a Rust crate, which implements a split Error handling mechanism. Specifically, it splits all errors into two kinds, internal and external errors. This distinction allows you to easily handle internal erros and user gateways, as any internal error, which is not supposed to be exposed to the user, can be easily converted into a generic external error.

Basic Usage

This is what's required to setup E-Error, crate two enums representing your internal and external errors, implement traits and finally merge into one EResult you can use everywhere.

#[derive(Debug)]
pub enum InErr {
    // stuff
}

impl e_error::InErr for InErr {
    // reports are like maps, except that they automatically call these Fns when the EResult is not Ok. Comes in useful when working with async code

    fn report(self, cause: Box<dyn std::error::Error + Send>, backtrace: std::backtrace::Backtrace) {
        // place some report handling here
    }
}

#[derive(Debug)]
pub enum ExtErr {
    // stuff
}

impl e_error::ExtErr for ExtErr {
    fn report(self) {
	    // here too
    }
}

type EResult<O> = e_error::EResult<O, InErr, ExtErr>;

Then use it like so.

use std::io::Error as ioError;
use std::io::ErrorKind as ioErrorKind;

let res: Result<String, ioError> = Err(ioError::new(ioErrorKind::ConnectionRefused, String::new()));

let wrapped: EResult<String> = res.internal(InErr::ConnectionRefused);