{"id":13503148,"url":"https://github.com/rust-lang-deprecated/failure","last_synced_at":"2025-09-27T10:30:49.451Z","repository":{"id":40779541,"uuid":"104799413","full_name":"rust-lang-deprecated/failure","owner":"rust-lang-deprecated","description":"Error management","archived":true,"fork":false,"pushed_at":"2020-05-02T18:12:26.000Z","size":1354,"stargazers_count":1421,"open_issues_count":109,"forks_count":137,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-09-15T12:24:00.065Z","etag":null,"topics":["error-handling","rust"],"latest_commit_sha":null,"homepage":"https://rust-lang-nursery.github.io/failure/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rust-lang-deprecated.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-25T20:35:41.000Z","updated_at":"2025-08-03T22:43:41.000Z","dependencies_parsed_at":"2022-09-17T10:30:21.525Z","dependency_job_id":null,"html_url":"https://github.com/rust-lang-deprecated/failure","commit_stats":null,"previous_names":["rust-lang-nursery/failure"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/rust-lang-deprecated/failure","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang-deprecated%2Ffailure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang-deprecated%2Ffailure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang-deprecated%2Ffailure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang-deprecated%2Ffailure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-lang-deprecated","download_url":"https://codeload.github.com/rust-lang-deprecated/failure/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang-deprecated%2Ffailure/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277218762,"owners_count":25781444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-27T02:00:08.978Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["error-handling","rust"],"created_at":"2024-07-31T22:02:38.953Z","updated_at":"2025-09-27T10:30:49.124Z","avatar_url":"https://github.com/rust-lang-deprecated.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# failure - a new error management story\n\n**Notice**: `failure` is deprecated. If you liked `failure`'s API, consider using:\n- [Anyhow](https://github.com/dtolnay/anyhow) is a good replacement for `failure::Error`.\n- [thiserror](https://github.com/dtolnay/thiserror) is a good, near drop-in replacement for `#[derive(Fail)]`.\n\n---\n\n[![Build Status](https://travis-ci.org/rust-lang-nursery/failure.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/failure)\n[![Latest Version](https://img.shields.io/crates/v/failure.svg)](https://crates.io/crates/failure)\n[![docs](https://docs.rs/failure/badge.svg)](https://docs.rs/failure)\n\n`failure` is designed to make it easier to manage errors in Rust. It is\nintended to replace error management based on `std::error::Error` with a new\nsystem based on lessons learned over the past several years, including those\nlearned from experience with quick-error and error-chain.\n\n`failure` provides two core components:\n\n* `Fail`: A new trait for custom error types.\n* `Error`: A struct which any type that implements `Fail` can be cast into.\n\n## Evolution\n\nFailure is currently evolving as a library.  First of all there is work going\non in Rust itself to [fix the error trait](https://github.com/rust-lang/rfcs/pull/2504)\nsecondarily the original plan for Failure towards 1.0 is unlikely to happen\nin the current form.\n\nAs such the original master branch towards 1.0 of failure was removed and\nmaster now represents the future iteration steps of 0.1 until it's clear\nwhat happens in the stdlib.\n\nThe original 1.0 branch can be found in [evolution/1.0](https://github.com/rust-lang-nursery/failure/tree/evolution/1.0).\n\n## Example\n\n```rust\nextern crate serde;\nextern crate toml;\n\n#[macro_use] extern crate failure;\n#[macro_use] extern crate serde_derive;\n\nuse std::collections::HashMap;\nuse std::path::PathBuf;\nuse std::str::FromStr;\n\nuse failure::Error;\n\n// This is a new error type that you've created. It represents the ways a\n// toolchain could be invalid.\n//\n// The custom derive for Fail derives an impl of both Fail and Display.\n// We don't do any other magic like creating new types.\n#[derive(Debug, Fail)]\nenum ToolchainError {\n    #[fail(display = \"invalid toolchain name: {}\", name)]\n    InvalidToolchainName {\n        name: String,\n    },\n    #[fail(display = \"unknown toolchain version: {}\", version)]\n    UnknownToolchainVersion {\n        version: String,\n    }\n}\n\npub struct ToolchainId {\n    // ... etc\n}\n\nimpl FromStr for ToolchainId {\n    type Err = ToolchainError;\n\n    fn from_str(s: \u0026str) -\u003e Result\u003cToolchainId, ToolchainError\u003e {\n        // ... etc\n    }\n}\n\npub type Toolchains = HashMap\u003cToolchainId, PathBuf\u003e;\n\n// This opens a toml file containing associations between ToolchainIds and\n// Paths (the roots of those toolchains).\n//\n// This could encounter an io Error, a toml parsing error, or a ToolchainError,\n// all of them will be thrown into the special Error type\npub fn read_toolchains(path: PathBuf) -\u003e Result\u003cToolchains, Error\u003e\n{\n    use std::fs::File;\n    use std::io::Read;\n\n    let mut string = String::new();\n    File::open(path)?.read_to_string(\u0026mut string)?;\n\n    let toml: HashMap\u003cString, PathBuf\u003e = toml::from_str(\u0026string)?;\n\n    let toolchains = toml.iter().map(|(key, path)| {\n        let toolchain_id = key.parse()?;\n        Ok((toolchain_id, path))\n    }).collect::\u003cResult\u003cToolchains, ToolchainError\u003e\u003e()?;\n\n    Ok(toolchains)\n}\n```\n\n## Requirements\n\nBoth failure and failure_derive are intended to compile on all stable versions\nof Rust newer than 1.31.0, as well as the latest beta and the latest nightly.\nIf either crate fails to compile on any version newer than 1.31.0, please open\nan issue.\n\nfailure is **no_std** compatible, though some aspects of it (primarily the\n`Error` type) will not be available in no_std mode.\n\n## License\n\nfailure is licensed under the terms of the MIT License or the Apache License\n2.0, at your choosing.\n\n## Code of Conduct\n\nContribution to the failure crate is organized under the terms of the\nContributor Covenant, the maintainer of failure, @withoutboats, promises to\nintervene to uphold that code of conduct.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-lang-deprecated%2Ffailure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-lang-deprecated%2Ffailure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-lang-deprecated%2Ffailure/lists"}