andrewdyer / andrewdyer/slim-api-template

Custom exception handling for proper REST status codes

Offen
#16 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
PHP
Sterne
0
Forks
0
Ø Merge
2 Std. 28 Min.
Gemergte PRs (30 T.)
3

Beschreibung

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_

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.