{"id":29656103,"url":"https://github.com/demirermustafa/problemnet","last_synced_at":"2025-07-22T08:31:20.389Z","repository":{"id":40879531,"uuid":"206024562","full_name":"demirermustafa/ProblemNet","owner":"demirermustafa","description":"A middleware to handle exceptions according to standards defined in https://tools.ietf.org/html/rfc7807 for HTTP Apis.","archived":false,"fork":false,"pushed_at":"2022-12-08T10:17:19.000Z","size":199,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-22T06:21:42.562Z","etag":null,"topics":["exception","exception-handler","exception-handling","middleware","problem-details","rfc7807"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/demirermustafa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-03T08:13:01.000Z","updated_at":"2022-06-28T20:39:27.000Z","dependencies_parsed_at":"2023-01-25T00:05:12.808Z","dependency_job_id":null,"html_url":"https://github.com/demirermustafa/ProblemNet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/demirermustafa/ProblemNet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demirermustafa%2FProblemNet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demirermustafa%2FProblemNet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demirermustafa%2FProblemNet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demirermustafa%2FProblemNet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/demirermustafa","download_url":"https://codeload.github.com/demirermustafa/ProblemNet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demirermustafa%2FProblemNet/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266456245,"owners_count":23931383,"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-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["exception","exception-handler","exception-handling","middleware","problem-details","rfc7807"],"created_at":"2025-07-22T08:30:56.379Z","updated_at":"2025-07-22T08:31:20.351Z","avatar_url":"https://github.com/demirermustafa.png","language":"C#","readme":"\n# ProblemNet\nProblemNET is a middleware library that implements rfc7807. The middleware catches all exceptions and handles according to exception type.    \nFor more information: https://tools.ietf.org/html/rfc7807\n## Installation\n\u003e  Install-Package ProblemNet  \n## Configuration\n```csharp\npublic class Startup\n{\n    public void ConfigureServices(IServiceCollection services)\n    {\n        services.AddProblemDetails(cfg =\u003e { cfg.DefaultTypeBaseUri = \"https://sample.com/problemdetails/\"; });\n\n            services.AddMvc().\n                     UseProblemDetailsInvalidModelStateResponseFactory();\n    }\n\n    public void Configure(IApplicationBuilder app)\n    {\n        app.UseProblemDetailsExceptionHandler();\n        ..\n        ..\n        ...\n    }\n}\n```\n\n## Usage\n### Creating Problems\nThere are different ways to create problems.  \n\n - **Simple**\n\n    ```csharp\n     throw new ProblemDetailsException()\n                      {\n                              Type = \"user-not-exists\",\n                              Title = \"User Not Exists\",\n                              Status = (int)HttpStatusCode.NotFound,\n                              Detail = \"Users cannot be found\"\n                      };\n    ```\n    Will produce this response\n    ```json\n      \"type\": \"https://userservice.com/problemdetails/user-not-exists\",\n      \"title\": \"User Not Exists\",\n      \"status\": 404,\n      \"detail\": \"Users cannot be found\",\n      \"instance\": \"/api/Samples/problem-details-simple\"\n    ```\n - **Additional Members**\n    ```csharp\n     throw new ProblemDetailsException\n                      {\n                              Status = (int)HttpStatusCode.NotFound,\n                              Title = $\"Users cannot be found\",\n                              Extensions =\n                              {\n                                      new KeyValuePair\u003cstring, object\u003e(\"Order\", new { OrderId = 1, OrderDate = DateTime.UtcNow, Status = \"Approved\" }),\n                                      new KeyValuePair\u003cstring, object\u003e(\"UserId\", 123)\n                              }\n                      };\n    ```\n\tWill produce this\n\t ```json\n      \"type\": \"https://userservice.com/problemdetails/\",\n      \"title\": \"Users cannot be found\",\n      \"status\": 404,\n      \"instance\": \"/api/Samples/problem-details-additional-members\",\n      \"order\": {\n        \"orderId\": 1,\n        \"orderDate\": \"2019-09-07T14:24:45.1783264Z\",\n        \"status\": \"Approved\"\n      },\n      \"userId\": 123\n\t  ```\n - **Custom Validation Exception**\n\n    ```csharp\n    var validationProblems = new List\u003cValidationProblem\u003e\n                                         {\n                                                 new ValidationProblem(\"FirstName\", \"FirstName length must be less than 50 characters\", \"FirstName should only contain letters\"),\n                                                 new ValidationProblem(\"Email\", \"Email address length must be greater than 5 characters\", \"Email address must be email format\")\n                                         };\n    throw new ValidationProblemDetailsException(validationProblems.ToArray())\n                      {\n                              Detail = \"Error while creating account. Please see errors for detail.\",\n                              Status = (int)HttpStatusCode.BadRequest,\n                              Title = \"Register Error\"\n                      };\n                \n    ```\n\tWill produce this\n\t ```json\n\t   ```\n - **Exceptions Except Problem Details**\n\n      ```csharp\n    throw new NullReferenceException();\n      ```\n\tWill produce the following output. If the environment is **development**, the content of the **exception property** will not be empty.\n\t ```json\n      \"exception\": {  },\n      \"type\": \"https://httpstatuses.com/500\",\n      \"title\": \"Internal Server Error\",\n      \"status\": 500,\n      \"detail\": \"An error occurred while processing your request\",\n      \"instance\": \"/api/Samples/unhandled-exception\"\n\t   ```\n### Response Headers\nThe same http response headers will be produced regardless of exception type on the lines below. Middleware also ensures that problem responses never cached.\n ```json\n\n    cache-control: no-cache, no-store, must-revalidate \n    content-type: application/problem+json; charset=utf-8 \n    date: Sat, 07 Sep 2019 14:03:55 GMT \n    expires: 0 \n    pragma: no-cache \n    server: Kestrel \n    transfer-encoding: chunked \n\n  ```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemirermustafa%2Fproblemnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdemirermustafa%2Fproblemnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemirermustafa%2Fproblemnet/lists"}