{"id":13503086,"url":"https://github.com/shepmaster/snafu","last_synced_at":"2025-05-11T05:46:06.794Z","repository":{"id":34053497,"uuid":"167827177","full_name":"shepmaster/snafu","owner":"shepmaster","description":"Easily assign underlying errors into domain-specific errors while adding context","archived":false,"fork":false,"pushed_at":"2024-11-19T17:21:04.000Z","size":981,"stargazers_count":1623,"open_issues_count":87,"forks_count":63,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-05-11T05:46:00.669Z","etag":null,"topics":["error-handling","rust"],"latest_commit_sha":null,"homepage":"https://docs.rs/snafu/","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/shepmaster.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-27T15:56:35.000Z","updated_at":"2025-05-10T10:43:59.000Z","dependencies_parsed_at":"2023-01-15T04:16:00.777Z","dependency_job_id":"f6c496bf-d164-4cfe-b887-c78956f99a45","html_url":"https://github.com/shepmaster/snafu","commit_stats":{"total_commits":498,"total_committers":34,"mean_commits":"14.647058823529411","dds":"0.13855421686746983","last_synced_commit":"90991b609e8928ceebf7df1b040408539d21adda"},"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shepmaster%2Fsnafu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shepmaster%2Fsnafu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shepmaster%2Fsnafu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shepmaster%2Fsnafu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shepmaster","download_url":"https://codeload.github.com/shepmaster/snafu/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253523720,"owners_count":21921818,"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","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:36.429Z","updated_at":"2025-05-11T05:46:06.759Z","avatar_url":"https://github.com/shepmaster.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# SNAFU\n\n**S**ituation **N**ormal: **A**ll **F**ouled **U**p\n\n[![crates.io][Crate Logo]][Crate]\n[![Documentation][Doc Logo]][Doc]\n[![Build Status][CI Logo]][CI]\n\nSNAFU is a library to easily assign underlying errors into\ndomain-specific errors while adding context.\n\n```rust\nuse snafu::prelude::*;\nuse std::{fs, io, path::PathBuf};\n\n#[derive(Debug, Snafu)]\nenum Error {\n    #[snafu(display(\"Unable to read configuration from {}\", path.display()))]\n    ReadConfiguration { source: io::Error, path: PathBuf },\n\n    #[snafu(display(\"Unable to write result to {}\", path.display()))]\n    WriteResult { source: io::Error, path: PathBuf },\n}\n\ntype Result\u003cT, E = Error\u003e = std::result::Result\u003cT, E\u003e;\n\nfn process_data() -\u003e Result\u003c()\u003e {\n    let path = \"config.toml\";\n    let configuration = fs::read_to_string(path).context(ReadConfigurationSnafu { path })?;\n    let path = unpack_config(\u0026configuration);\n    fs::write(\u0026path, b\"My complex calculation\").context(WriteResultSnafu { path })?;\n    Ok(())\n}\n\nfn unpack_config(data: \u0026str) -\u003e \u0026str {\n    \"/some/path/that/does/not/exist\"\n}\n```\n\nPlease see [the documentation][Doc] and the [user's guide][Guide] for\na full description.\n\n[Crate]: https://crates.io/crates/snafu\n[Crate Logo]: https://img.shields.io/crates/v/snafu.svg\n\n[Doc]: https://docs.rs/snafu\n[Doc Logo]: https://docs.rs/snafu/badge.svg\n[Guide]: https://docs.rs/snafu/*/snafu/guide/index.html\n\n[CI]: https://cirrus-ci.com/github/shepmaster/snafu\n[CI Logo]: https://api.cirrus-ci.com/github/shepmaster/snafu.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshepmaster%2Fsnafu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshepmaster%2Fsnafu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshepmaster%2Fsnafu/lists"}