{"id":20643648,"url":"https://github.com/bitzart/apiexceptions","last_synced_at":"2025-04-16T02:03:04.010Z","repository":{"id":42366201,"uuid":"391014430","full_name":"BitzArt/ApiExceptions","owner":"BitzArt","description":"Reinventing C# exceptions","archived":false,"fork":false,"pushed_at":"2024-04-02T06:52:44.000Z","size":498,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-23T21:03:24.994Z","etag":null,"topics":["asp-net-core","aspnetcore","csharp","dotnet","exception-handling","exceptions"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BitzArt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"custom":["https://paypal.me/BitzArtDev"]}},"created_at":"2021-07-30T09:51:35.000Z","updated_at":"2025-01-28T11:53:55.000Z","dependencies_parsed_at":"2024-11-16T16:13:39.311Z","dependency_job_id":"17544a97-0202-49fc-9b93-bf94187dcf35","html_url":"https://github.com/BitzArt/ApiExceptions","commit_stats":null,"previous_names":[],"tags_count":58,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitzArt%2FApiExceptions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitzArt%2FApiExceptions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitzArt%2FApiExceptions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitzArt%2FApiExceptions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BitzArt","download_url":"https://codeload.github.com/BitzArt/ApiExceptions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249183099,"owners_count":21226140,"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":["asp-net-core","aspnetcore","csharp","dotnet","exception-handling","exceptions"],"created_at":"2024-11-16T16:13:30.972Z","updated_at":"2025-04-16T02:03:03.979Z","avatar_url":"https://github.com/BitzArt.png","language":"C#","funding_links":["https://paypal.me/BitzArtDev"],"categories":[],"sub_categories":[],"readme":"![Tests](https://github.com/BitzArt/ApiExceptions/actions/workflows/Tests.yml/badge.svg)\n\n\n# General\n\nThis library defines `ApiExceptions` that you can throw in your .Net applications.\n\n# Use with Asp.Net Core\n\n\u003e 💡\n\u003e You can always refer to [this](https://github.com/BitzArt/ApiExceptions/tree/main/sample/BitzArt.ApiExceptions.AspNetCore.Sample) sample project for guidance.\n\n## Setup:\n\nAdd the nuget package:\n\n```\ndotnet add package BitzArt.ApiExceptions.AspNetCore\n```\n\nAdd this line to your `Program.cs` when configuring services:\n```csharp\nbuilder.Services.AddApiExceptionHandler();\n```\n\nAdd this line to your `Program.cs` when configuring the request pipeline:\n```csharp\n// This line should go before any other middleware that might throw exceptions\napp.UseApiExceptionHandler();\n```\n\n## Usage:\nThen, anywhere in your code, you can throw exceptions like:\n```csharp\nthrow ApiException.BadRequest(\"your error message\");\n```\nThis will stop any further execution and generate an http response with an appropriate http status code.\n\nThe package handles both ApiExceptions as well as regular Exceptions. If the exception is of type `ApiException`, it will generate a response with the appropriate status code and message. If the exception is of type `Exception`, the status code will be `500`.\n\n\u003e 💡\n\u003e These responses are aligned with [RFC7807: Problem Details for HTTP APIs](https://www.rfc-editor.org/rfc/rfc7807).\n\n# Use outside of Asp.Net Core\n\nTo use `ApiExceptions` in your applications, add this nuget package to your project:\n\n```\ndotnet add package BitzArt.ApiExceptions\n```\n\nThis will allow you to create and throw ApiExceptions, and you can then handle them as you see fit.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitzart%2Fapiexceptions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitzart%2Fapiexceptions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitzart%2Fapiexceptions/lists"}