#error #error-handling #wrapper #handling

borked

Simple and convienient error handling library for rust

2 releases

0.1.2 Aug 12, 2021
0.1.1 Aug 12, 2021
0.1.0 Jan 1, 2021

#2654 in Rust patterns

Custom license

18KB
236 lines

Rust-Borked

Error handling for rust.

This Does a very similar thing to existing projects like failure - Rust or error_chain but I was never quite satisfied with the other implementations.

This was my first time really mucking about with Rust's Trait system, so if I did anything incrdably dumb, or if improvments could otherwise be made, I'd love to hear about it. :)

Install

borked is on crates.io so it can be added to Cargo.toml:

[dependencies]
...
borked = "0.1.0"

Example

This crate provides features for working with any error that implements the std::error::Error Trait. But Types implementing BorkChain are most useful with this crate.

#[macro_use]
extern crate borked;
use borked::*;

fn doing_stuff() -> Borkable<u32>{
	// Do something useful...
	// Encounter error...
	Bork!("Oh No!");
	// Never reached in this case.
	return Ok(0);
}

fn q_mark()-> Borkable<u32>{
	let e = u32::from_str_radix("Obviously_not_gonna_work", 10)?;
	return Ok(e);
}

fn with_bork() -> Borkable<u32>{
	let e = u32::from_str_radix("Obviously_not_gonna_work", 10)
		.bork_with(BaseBork::msg("AHHH It Didn't Work!"))?;
	return Ok(e+7);

}

No runtime deps