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.
This adds a new interface
ExceptionHandler
discussed in #374 which is designed to handle uncaught exceptions from aRequestHandler
as part of the middleware stack usingExceptionHandlerMiddleware
. The interface specifies a single method which takes the uncaught exception and associatedRequest
, returning aResponse
.There is a default implementation provided by
DefaultExceptionHandler
, which logs the uncaught exception to theLoggerInterface
instance provided, then returns a response generated by a delegateErrorHandler
.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.