GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - FloppyShelf/Problemize: This package offers a robust, extensible framework for centralized exception handling in .NET Web APIs. It standardizes error responses with ProblemDetails, supports custom exceptions, and features flexible status code mapping. Integrated via middleware, it ensures clean, maintainable global error handling.

BranchesTags
Open more actions menu

Latest commit

 

History

5 Commits
5 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
assets/logo
assets/logo
 
 
docs/reviews
docs/reviews
 
 
src/Problemize
src/Problemize
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
Directory.Build.props
Directory.Build.props
 
 
Directory.Packages.props
Directory.Packages.props
 
 
LICENSE
LICENSE
 
 
Problemize.slnx
Problemize.slnx
 
 
README.md
README.md
 
 

Repository files navigation

FloppyShelf.Problemize

Problemize

This package provides a robust and extensible framework for centralized exception handling in .NET Web APIs. It standardizes error responses using ProblemDetails, supports custom exceptions and includes a flexible status code mapping system. The package integrates seamlessly via middleware and service configuration, making global error handling clean and maintainable.

Features

IStatusCodeMapper An interface to decouple the logic of mapping exceptions to HTTP status codes. Makes it easy to extend or override.

StatusCodeMapper Default implementation of IStatusCodeMapper, handling common .NET exceptions like ArgumentException, UnauthorizedAccessException and NotImplementedException.

ExceptionHandler Implements IExceptionHandler from ASP.NET Core. This service:

  • Maps the exception to an HTTP status code.
  • Converts exceptions into a standardized ProblemDetails or ValidationProblemDetails.
  • Writes the response using IProblemDetailsService.

Configurator Contains extension methods for:

  • Registering services
  • Configuring middleware

Setup Instructions

  1. Register services in Program.cs
builder.Services.UseExceptionHandling();
  1. Configure middleware in Program.cs
app.UseExceptionHandling();

Sample ProblemDetails response

{
  "title": "An error occured while validating your request",
  "detail": "Invalid data",
  "type": "ValidationException",
  "status": 400,
  "instance": "POST /api/users",
  "extensions": {
    "requestId": "00-abcd1234...",
    "activityId": "00-xyz5678..."
  }
}

About

This package offers a robust, extensible framework for centralized exception handling in .NET Web APIs. It standardizes error responses with ProblemDetails, supports custom exceptions, and features flexible status code mapping. Integrated via middleware, it ensures clean, maintainable global error handling.

Topics

apiaspnetcorecentralized-loggingcustom-exceptionserror-handlingexception-handlingextensibilityglobal-exception-handlersmaintainablemiddlewareproblem-detailsrobuststatuscode-mappingvalidation-errorswebapi

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.