{"id":29608530,"url":"https://github.com/mehcode/axum-error-object","last_synced_at":"2025-07-20T19:36:12.998Z","repository":{"id":294099427,"uuid":"972172636","full_name":"mehcode/axum-error-object","owner":"mehcode","description":"Provides a Result\u003cT\u003e type and related utility types that can be used to holistically provide object response errors.","archived":false,"fork":false,"pushed_at":"2025-05-18T23:19:32.000Z","size":27,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-19T04:20:27.306Z","etag":null,"topics":["anyhow","axum","error"],"latest_commit_sha":null,"homepage":"","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/mehcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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-04-24T16:41:09.000Z","updated_at":"2025-05-26T21:41:06.000Z","dependencies_parsed_at":"2025-05-18T23:43:54.459Z","dependency_job_id":null,"html_url":"https://github.com/mehcode/axum-error-object","commit_stats":null,"previous_names":["mehcode/axum-error-object"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mehcode/axum-error-object","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehcode%2Faxum-error-object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehcode%2Faxum-error-object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehcode%2Faxum-error-object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehcode%2Faxum-error-object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mehcode","download_url":"https://codeload.github.com/mehcode/axum-error-object/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehcode%2Faxum-error-object/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266187950,"owners_count":23890013,"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":["anyhow","axum","error"],"created_at":"2025-07-20T19:35:54.242Z","updated_at":"2025-07-20T19:36:12.962Z","avatar_url":"https://github.com/mehcode.png","language":"Rust","readme":"# axum-error-object\n\nProvides a `Result\u003cT\u003e` type and related utility types\nthat can be used to holistically provide object response errors.\n\n## Install\n\n```toml\naxum-error-object = \"0.0.1\"\n```\n\n## Usage\n\n```rust\nuse axum_error_object::{Result, Status, Context, IntoErrorResponse};\nuse serde::Serialize;\nuse derive_more::Display;\n\nfn call_fallible() -\u003e std::result::Result\u003cT, E\u003e { /* ... */ }\nfn call_maybe() -\u003e Option\u003cT\u003e { /* ... */ }\n\n#[derive(Display, ErrorResponse, Serialize)]\n#[serde(rename_all = \"snake_case\", tag = \"code\", content = \"meta\")]\nenum AppError {\n  #[display(\"Whoa there that is {that}\")]\n  #[response(status = 420)]\n  WhoaThere { that: u8 },\n\n  #[display(\"Oh No\")]\n  #[response(status = 501)]\n  OhNo,\n}\n\nasync fn handler() -\u003e Result\u003cStatusCode\u003e {\n  // will return an opaque 500 on any unhandled error or None\n  call_fallible()?;\n  call_maybe()?;\n\n  // will return an opaque 404 on None or error\n  call_fallible().status(StatusCode::NOT_FOUND)?;\n  call_maybe().status(StatusCode::NOT_FOUND)?;\n\n  // will return the following 420 response:\n  //  {\n  //    \"code\": \"whoa_there\",\n  //    \"title\": \"Whoa there that is 10\",\n  //    \"meta\": { \"that\": 10 }\n  //  }\n  // preserves the original error information as source (does not return from the API)\n  // useful for logs and inspection\n  call_fallible().with_context(|| AppError::WhoaThere { that: 30 })?;\n  call_fallible().context(AppError::OhNo)?;\n  call_maybe().context(AppError::OhNo)?;\n\n  // return ok\n  Ok(StatusCode::OK)\n}\n```\n\n## License\n\nLicensed under either of\n\nApache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)\nMIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)\nat your option.\n\n**Contribution**\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmehcode%2Faxum-error-object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmehcode%2Faxum-error-object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmehcode%2Faxum-error-object/lists"}