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

Add ExceptionHandler interface and middleware #375

Merged
merged 6 commits into from
Nov 22, 2024
Merged

Conversation

trowski
Copy link
Member

@trowski trowski commented Nov 9, 2024

This adds a new interface ExceptionHandler discussed in #374 which is designed to handle uncaught exceptions from a RequestHandler as part of the middleware stack using ExceptionHandlerMiddleware. The interface specifies a single method which takes the uncaught exception and associated Request, returning a Response.

There is a default implementation provided by DefaultExceptionHandler, which logs the uncaught exception to the LoggerInterface instance provided, then returns a response generated by a delegate ErrorHandler.

I've added a parameter to the static constructors of SocketHttpServer for better discovery of the interface, and will add docs to the readme if merged.

@trowski trowski requested a review from kelunik November 9, 2024 16:41
src/DefaultExceptionHandler.php Outdated Show resolved Hide resolved
src/Driver/Internal/AbstractHttpDriver.php Outdated Show resolved Hide resolved
src/Driver/Internal/AbstractHttpDriver.php Outdated Show resolved Hide resolved
@trowski trowski merged commit c5bad9b into 3.x Nov 22, 2024
12 checks passed
@trowski trowski deleted the exception-handler branch November 22, 2024 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants