Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement of error handling capabilities #56

Merged
merged 1 commit into from
Sep 4, 2024
Merged

Conversation

phamtiendungcw
Copy link
Owner

Improves error handling by adding specific response types and introducing a global exception middleware.

  • Added ProducesResponseType(StatusCodes.Status404NotFound) to various controller methods.
  • Introduced ExceptionMiddleware for global exception handling and updated Program.cs to use it.
  • Created CustomProblemDetails class for detailed error responses.
  • Refactored BadRequestException to use a dictionary for validation errors.
  • Corrected a typo in appsettings.json.

Reordered using directives in ExceptionMiddleware.cs and added a new directive for MLS.Application.Exceptions.
Added a new case for handling NotFoundException in ExceptionMiddleware class, setting statusCode to HttpStatusCode.NotFound and creating a CustomProblemDetails object.
Added a default case to handle other exceptions, setting problem details accordingly.
Refactored CustomProblemDetails class in CustomProblemDetails.cs, moving class definition outside of the nested block and retaining the Errors property.
@phamtiendungcw phamtiendungcw merged commit 02190d8 into master Sep 4, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant