andrewdyer / andrewdyer/slim-api-template
Custom exception handling for proper REST status codes
- Lingua principale
- PHP
- Stelle
- 0
- Fork
- 0
- Merge medio
- 2h 28m
- PR unite (30g)
- 3
Descrizione
With only the default ErrorMiddleware configured, domain/input exceptions (e.g., UserNotFoundException, InvalidArgumentException from DTO parsing) will surface as 500 responses. For a REST API this should normally be translated into 404 (not found) / 400 (bad request) to avoid misclassifying client errors as server errors; consider registering custom exception handlers (or throwing Slim HttpNotFoundException/HttpBadRequestException) so actions return appropriate status codes.
_Originally posted by @Copilot in https://github.com/andrewdyer/slim-app-template/pull/15#discussion_r3008602984_
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.