borked

Crates.ioborked
lib.rsborked
version0.1.2
sourcesrc
created_at2021-01-01 21:29:27.838852
updated_at2021-08-12 20:55:05.770864
descriptionSimple and convienient error handling library for rust
homepage
repositoryhttps://gitlab.com/Tristan_C/rust-borked
max_upload_size
id330296
size52,486
(StanTh3Man)

documentation

README

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);

}
Commit count: 10

cargo fmt