app-error 0.1.0

Error type for applications
Documentation
  • Coverage
  • 87.5%
    28 out of 32 items documented0 out of 25 items with examples
  • Size
  • Source code size: 43.78 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.76 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 23s Average build duration of successful builds.
  • all releases: 23s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Zenithsiz/app-error
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Zenithsiz

App error

This crate provides an error type, AppError, that is intended for usage in applications.

It is Send, Sync, 'static, and, importantly, cheaply Clone-able.

To achieve this, it serializes every error it receives without owning it, meaning that you also can't retrieve the error later by downcasting it.

It is also able to store multiple errors at once and provide pretty-printing of all of these them.

It can carry an optional data parameter that may be retrieved later on.

Examples

use app_error::{AppError, Context, app_error};

fn fallible_fn1() -> Result<(), AppError> {
	// Create an error
	Err(app_error!("Fn1 failed!"))
}

fn fallible_fn2() -> Result<(), AppError> {
	// Add context to results
	fallible_fn1().context("Fn2 failed!")
}

fn main() {
	let err = fallible_fn2().expect_err("Will return an error");

	// Pretty printing:
	// ```
	// Fn2 failed!
	// └─Fn1 failed!
	// ```
	println!("{err:?}");
}