Skip to content

Feature/exceptions+error handling - #37

Closed
LuisCartucho wants to merge 5 commits into
devfrom
feature/Exceptions+errorHandling
Closed

LuisCartucho wants to merge 5 commits into
devfrom
feature/Exceptions+errorHandling

Conversation

@LuisCartucho

Copy link
Copy Markdown
Collaborator

Exception Handling Overview

This PR uses a centralized API exception system located in the Errors folder.

ApiException
Custom exception representing intentional API errors with an HTTP status code and message.

ApiErrors
Factory helpers (BadRequest, Unauthorized, NotFound, etc.) used in services to throw semantic, consistent API errors.

ApiExceptionMiddleware
Global middleware that catches exceptions, converts ApiException instances into proper HTTP responses, and returns 500 for unexpected errors.

Why:
Keeps controllers clean, avoids scattered try/catch blocks, ensures consistent error responses, and prevents leaking internal exceptions to clients.

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