All Projects → rust-lang-nursery → Failure

rust-lang-nursery / Failure

Licence: other
Error management

Programming Languages

rust
11053 projects
shell
77523 projects
Makefile
30231 projects

Projects that are alternatives of or similar to Failure

Cvdm.errorhandling
[DEPRECATED, use FsToolkit.ErrorHandling] AsyncResult and Result computation expressions and helper functions for error handling in F#
Stars: ✭ 47 (-96.77%)
Mutual labels:  error-handling
Mjn
⚡️Like loadash.get, but in ~200 bytes
Stars: ✭ 69 (-95.26%)
Mutual labels:  error-handling
React Native Device Log
A UI and service for handling/displaying dev log messages on devices
Stars: ✭ 96 (-93.4%)
Mutual labels:  error-handling
Panic Overlay
Displays JS errors in browsers. Shows sources. Use with any framework. 💥✨
Stars: ✭ 50 (-96.56%)
Mutual labels:  error-handling
Cli Error Notifier
Sends native desktop notifications if CLI apps fail
Stars: ✭ 61 (-95.81%)
Mutual labels:  error-handling
Apollo Prophecy
🔮 GraphQL error management made Easy, generate custom machine-readable errors for Apollo Client/Server from the CLI
Stars: ✭ 83 (-94.3%)
Mutual labels:  error-handling
Bugsnag Android Ndk
DEPRECATED - this project now lives at bugsnag/bugsnag-android
Stars: ✭ 42 (-97.11%)
Mutual labels:  error-handling
Production Ready Expressjs Server
Express.js server that implements production-ready error handling and logging following latest best practices.
Stars: ✭ 101 (-93.06%)
Mutual labels:  error-handling
Extensible Custom Error
JavaScript extensible custom error that can take a message and/or an Error object
Stars: ✭ 64 (-95.6%)
Mutual labels:  error-handling
Ok jose
Pipe elixir functions that match ok/error tuples or custom patterns.
Stars: ✭ 91 (-93.75%)
Mutual labels:  error-handling
Searcher
Query Search Portals from R
Stars: ✭ 59 (-95.95%)
Mutual labels:  error-handling
Resulttypes.jl
A Result type for Julia—it's like Nullables for Exceptions
Stars: ✭ 60 (-95.88%)
Mutual labels:  error-handling
Errdo
A simple plugin to handle, log, and customize production errors in Rails applications
Stars: ✭ 88 (-93.95%)
Mutual labels:  error-handling
Bugsnag Node
[DEPRECATED] Please upgrade to our Universal JS notifier "@bugsnag/js" • https://github.com/bugsnag/bugsnag-js
Stars: ✭ 48 (-96.7%)
Mutual labels:  error-handling
Tracy
😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.
Stars: ✭ 1,345 (-7.56%)
Mutual labels:  error-handling
Progress Activity
Easily add loading, empty and error states in your app.
Stars: ✭ 1,039 (-28.59%)
Mutual labels:  error-handling
Laravel Console Logger
Logging and Notifications for Laravel Console Commands.
Stars: ✭ 79 (-94.57%)
Mutual labels:  error-handling
Raygun4net
Raygun provider for .NET
Stars: ✭ 107 (-92.65%)
Mutual labels:  error-handling
Faux Pas
A library that simplifies error handling for Functional Programming in Java
Stars: ✭ 100 (-93.13%)
Mutual labels:  error-handling
Node rollbar
DEPRECATED - please use rollbar.js
Stars: ✭ 89 (-93.88%)
Mutual labels:  error-handling

failure - a new error management story

Notice: failure is deprecated. If you liked failure's API, consider using:

  • Anyhow is a good replacement for failure::Error.
  • thiserror is a good, near drop-in replacement for #[derive(Fail)].

Build Status Latest Version docs

failure is designed to make it easier to manage errors in Rust. It is intended to replace error management based on std::error::Error with a new system based on lessons learned over the past several years, including those learned from experience with quick-error and error-chain.

failure provides two core components:

  • Fail: A new trait for custom error types.
  • Error: A struct which any type that implements Fail can be cast into.

Evolution

Failure is currently evolving as a library. First of all there is work going on in Rust itself to fix the error trait secondarily the original plan for Failure towards 1.0 is unlikely to happen in the current form.

As such the original master branch towards 1.0 of failure was removed and master now represents the future iteration steps of 0.1 until it's clear what happens in the stdlib.

The original 1.0 branch can be found in evolution/1.0.

Example

extern crate serde;
extern crate toml;

#[macro_use] extern crate failure;
#[macro_use] extern crate serde_derive;

use std::collections::HashMap;
use std::path::PathBuf;
use std::str::FromStr;

use failure::Error;

// This is a new error type that you've created. It represents the ways a
// toolchain could be invalid.
//
// The custom derive for Fail derives an impl of both Fail and Display.
// We don't do any other magic like creating new types.
#[derive(Debug, Fail)]
enum ToolchainError {
    #[fail(display = "invalid toolchain name: {}", name)]
    InvalidToolchainName {
        name: String,
    },
    #[fail(display = "unknown toolchain version: {}", version)]
    UnknownToolchainVersion {
        version: String,
    }
}

pub struct ToolchainId {
    // ... etc
}

impl FromStr for ToolchainId {
    type Err = ToolchainError;

    fn from_str(s: &str) -> Result<ToolchainId, ToolchainError> {
        // ... etc
    }
}

pub type Toolchains = HashMap<ToolchainId, PathBuf>;

// This opens a toml file containing associations between ToolchainIds and
// Paths (the roots of those toolchains).
//
// This could encounter an io Error, a toml parsing error, or a ToolchainError,
// all of them will be thrown into the special Error type
pub fn read_toolchains(path: PathBuf) -> Result<Toolchains, Error>
{
    use std::fs::File;
    use std::io::Read;

    let mut string = String::new();
    File::open(path)?.read_to_string(&mut string)?;

    let toml: HashMap<String, PathBuf> = toml::from_str(&string)?;

    let toolchains = toml.iter().map(|(key, path)| {
        let toolchain_id = key.parse()?;
        Ok((toolchain_id, path))
    }).collect::<Result<Toolchains, ToolchainError>>()?;

    Ok(toolchains)
}

Requirements

Both failure and failure_derive are intended to compile on all stable versions of Rust newer than 1.31.0, as well as the latest beta and the latest nightly. If either crate fails to compile on any version newer than 1.31.0, please open an issue.

failure is no_std compatible, though some aspects of it (primarily the Error type) will not be available in no_std mode.

License

failure is licensed under the terms of the MIT License or the Apache License 2.0, at your choosing.

Code of Conduct

Contribution to the failure crate is organized under the terms of the Contributor Covenant, the maintainer of failure, @withoutboats, promises to intervene to uphold that code of conduct.

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].