{"id":26260881,"url":"https://github.com/conduition/simplerror","last_synced_at":"2026-02-09T04:36:33.153Z","repository":{"id":280090036,"uuid":"925530501","full_name":"conduition/simplerror","owner":"conduition","description":"Simple zero-dependency Rust macro to declaratively define your error enums. ","archived":false,"fork":false,"pushed_at":"2025-02-01T06:44:26.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-04T22:50:24.881Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/conduition.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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,"zenodo":null}},"created_at":"2025-02-01T04:45:32.000Z","updated_at":"2025-02-01T06:47:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"c1744235-9a90-48d1-9527-918d7d9897c8","html_url":"https://github.com/conduition/simplerror","commit_stats":null,"previous_names":["conduition/simplerror"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/conduition/simplerror","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conduition%2Fsimplerror","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conduition%2Fsimplerror/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conduition%2Fsimplerror/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conduition%2Fsimplerror/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/conduition","download_url":"https://codeload.github.com/conduition/simplerror/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conduition%2Fsimplerror/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268248744,"owners_count":24219557,"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-08-01T02:00:08.611Z","response_time":67,"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":[],"created_at":"2025-03-13T23:17:17.738Z","updated_at":"2026-02-09T04:36:33.089Z","avatar_url":"https://github.com/conduition.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simplerror\n\nA zero-dependency Rust macro to declaratively define your error enums with automatic `From`, `Display`, and `Error` trait implementations. Declare error types which automatically wrap an inner error type while also providing detailed formatted error messages.\n\n```rust\nsimplerror::declare! {\n    pub enum MyError {\n        SimpleMember =\u003e \"something went wrong\",\n        SomeMember(e1: String) =\u003e \"1234 {e1}\",\n        AnotherMember(e1: String, e2: String) =\u003e \"1234 {e1} {e2}\",\n        BasicMember, // Display::fmt writes \"MyError::BasicMember\"\n    }\n\n    pub enum AnotherError {\n        Variant1,\n        Variant2 =\u003e \"message\",\n        ComposedVariant(e: MyError) =\u003e \"an inner error: {e}\",\n    }\n}\n\nassert_eq!(MyError::SimpleMember.to_string(), \"something went wrong\");\nassert_eq!(\n    MyError::SomeMember(\"5678\".to_string()).to_string(),\n    \"1234 5678\"\n);\nassert_eq!(\n    AnotherError::ComposedVariant(MyError::SimpleMember).to_string(),\n    \"an inner error: something went wrong\"\n);\n```\n\n`From` implementations are handled automatically for any enum members which wrap a single value.\n\n```rust\n#[derive(Debug)]\nstruct Foo;\n\nsimplerror::declare! {\n    pub(crate) enum CustomError {\n        Failure =\u003e \"We failed...\",\n    }\n\n    // This enum automatically implements From\u003cCustomError\u003e by returning `Self::Wrapped(CustomError)`\n    pub(crate) enum WrappingError {\n        Wrapped(e: CustomError) =\u003e \"wrapped: {e}\",\n    }\n}\n\nfn fail_inner() -\u003e Result\u003c(), CustomError\u003e {\n    Err(CustomError::Failure)\n}\n\nfn fail_outer() -\u003e Result\u003c(), WrappingError\u003e {\n    fail_inner()?;\n    Ok(())\n}\n\nassert!(matches!(\n    fail_outer(),\n    Err(WrappingError::Wrapped(CustomError::Failure))\n));\n```\n\nTo derive extra traits on your error enum, or run other procedural macros, you can add them like so above each enum declaration or enum variant like so.\n\n```rust\nsimplerror::declare! {\n    #[derive(PartialEq)]\n    #[cfg_attr(test, derive(serde::Serialize))]\n    enum MyError {\n        #[cfg_attr(test, serde(rename_all = \"ERR_NOT_FOUND\"))]\n        ErrorCode404 =\u003e \"didn't find it\",\n    }\n}\n\nimpl MyError {\n    fn is_404(\u0026self) -\u003e bool {\n        self == \u0026Self::ErrorCode404\n    }\n}\n```\n\n\u003e [!WARNING]\n\u003e To conditionally compile a certain enum, you can wrap the entire `declare!` invocation in your compilation flag.\n\u003e\n\u003e If you conditionally compile enum members, or configure-out the enum type itself, you'll encounter compilation errors due to missing references on the automatic trait implementations which `declare!` generates.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconduition%2Fsimplerror","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconduition%2Fsimplerror","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconduition%2Fsimplerror/lists"}