For HTTP, the servlet-interceptor.adoc provides the "last
ditch" error handlers that log the error and return an error response. In
development mode, they emit a formatted stack trace as the response body; you will see
the error logged from the :io.pedestal.http.impl.servlet-interceptor/stylobate
interceptor.
|
|
The error logged by the "last ditch" error handler includes the context
map. This is often quite large and may contain data you do not wish to log.
|
While having defaults is nice, it is highly recommended that services implement
their own error handling/logging. This gives you full control over how errors
are processed.
Some exceptions should not be logged; by default, Pedestal will identify
an exception that indicates a broken pipe to the client when sending the response; such errors will not be
logged but will be quietly ignored.
An exception analyzer function is passed the context-map.adoc and the unhandled exception;
it may return nil to prevent the exception from being logged, or return the exception itself,
or an alternate exception, to have that be the exception that is logged.
When the analyzer returns an exception and nothing has been sent to the client yet (the response is not committed),
Pedestal discards the response and sends a 500 status instead. When the analyzer returns nil, Pedestal does
not change the response.
When not specified, the api:default-exception-analyzer[ns=io.pedestal.http.impl.servlet-interceptor] function is used;
this is where the logic to check for a broken pipe exception lives.