All Projects → shepmaster → Snafu

shepmaster / Snafu

Licence: other
Easily assign underlying errors into domain-specific errors while adding context

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Snafu

Sentry Miniapp
Sentry 小程序/小游戏 SDK:用于小程序/小游戏平台的 Sentry SDK(目前支持微信、字节跳动、支付宝、钉钉、QQ、百度小程序,微信、QQ 小游戏)
Stars: ✭ 269 (-57.3%)
Mutual labels:  error-handling
Stateviews
Create & Show progress, data or error views, the easy way!
Stars: ✭ 367 (-41.75%)
Mutual labels:  error-handling
Traceback with variables
Adds variables to python traceback. Simple, lightweight, controllable. Debug reasons of exceptions by logging or pretty printing colorful variable contexts for each frame in a stacktrace, showing every value. Dump locals environments after errors to console, files, and loggers. Works in Jupyter and IPython. Install with pip or conda.
Stars: ✭ 509 (-19.21%)
Mutual labels:  error-handling
Hamsters
A mini Scala utility library
Stars: ✭ 292 (-53.65%)
Mutual labels:  error-handling
Swift Validated
🛂 A result type that accumulates multiple errors.
Stars: ✭ 350 (-44.44%)
Mutual labels:  error-handling
Stacktrace.js
Generate, parse, and enhance JavaScript stack traces in all web browsers
Stars: ✭ 3,793 (+502.06%)
Mutual labels:  error-handling
Verifier
Package verifier provides simple defensive programing primitives.
Stars: ✭ 264 (-58.1%)
Mutual labels:  error-handling
Rxdogtag
Automatic tagging of RxJava 2+ originating subscribe points for onError() investigation.
Stars: ✭ 601 (-4.6%)
Mutual labels:  error-handling
Tbvaccine
A small utility to pretty-print Python tracebacks. ⛺
Stars: ✭ 358 (-43.17%)
Mutual labels:  error-handling
Rollbar.js
Error tracking and logging from JS to Rollbar
Stars: ✭ 479 (-23.97%)
Mutual labels:  error-handling
Rollbar Php
Error tracking and logging from PHP to Rollbar
Stars: ✭ 297 (-52.86%)
Mutual labels:  error-handling
Data Structures
Go datastructures.
Stars: ✭ 336 (-46.67%)
Mutual labels:  error-handling
Log Process Errors
Show some ❤️ to Node.js process errors
Stars: ✭ 424 (-32.7%)
Mutual labels:  error-handling
Error Stack Parser
Extract meaning from JS Errors
Stars: ✭ 280 (-55.56%)
Mutual labels:  error-handling
Reattempt
🤞 Give your functions another chance
Stars: ✭ 570 (-9.52%)
Mutual labels:  error-handling
Fluentresults
A generalised Result object implementation for .NET/C#
Stars: ✭ 266 (-57.78%)
Mutual labels:  error-handling
Bugsnag React Native
Error monitoring and reporting tool for native exceptions and JS errors in React Native apps
Stars: ✭ 374 (-40.63%)
Mutual labels:  error-handling
Bugsnag Js
Javascript error handling tool for Bugsnag. Monitor and report JavaScript bugs & errors.
Stars: ✭ 625 (-0.79%)
Mutual labels:  error-handling
Bash Oo Framework
Bash Infinity is a modern standard library / framework / boilerplate for Bash
Stars: ✭ 5,247 (+732.86%)
Mutual labels:  error-handling
Bugsnag Php
Bugsnag error monitoring and crash reporting tool for PHP apps
Stars: ✭ 475 (-24.6%)
Mutual labels:  error-handling

SNAFU

Situation Normal: All Fouled Up

crates.io Documentation Build Status

SNAFU is a library to easily assign underlying errors into domain-specific errors while adding context.

use snafu::{ResultExt, Snafu};
use std::{fs, io, path::PathBuf};

#[derive(Debug, Snafu)]
enum Error {
    #[snafu(display("Unable to read configuration from {}: {}", path.display(), source))]
    ReadConfiguration { source: io::Error, path: PathBuf },

    #[snafu(display("Unable to write result to {}: {}", path.display(), source))]
    WriteResult { source: io::Error, path: PathBuf },
}

type Result<T, E = Error> = std::result::Result<T, E>;

fn process_data() -> Result<()> {
    let path = "config.toml";
    let configuration = fs::read_to_string(path).context(ReadConfiguration { path })?;
    let path = unpack_config(&configuration);
    fs::write(&path, b"My complex calculation").context(WriteResult { path })?;
    Ok(())
}

fn unpack_config(data: &str) -> &str {
    "/some/path/that/does/not/exist"
}

Please see the documentation and the user's guide for a full description.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].