|
36 | 36 | import io.fusionauth.http.server.HTTPRequest; |
37 | 37 | import io.fusionauth.http.server.HTTPResponse; |
38 | 38 | import io.fusionauth.http.server.HTTPServerConfiguration; |
39 | | -import io.fusionauth.http.server.HTTPUnexpectedExceptionHandler; |
40 | 39 | import io.fusionauth.http.server.Instrumenter; |
41 | 40 | import io.fusionauth.http.server.io.ConnectionClosedException; |
42 | 41 | import io.fusionauth.http.server.io.HTTPInputStream; |
@@ -268,24 +267,10 @@ public void run() { |
268 | 267 | logger.debug(String.format("[%s] Closing socket with status [%d]. An IO exception was thrown during processing. These are pretty common.", Thread.currentThread().threadId(), Status.InternalServerError), e); |
269 | 268 | closeSocketOnError(response, Status.InternalServerError); |
270 | 269 | } catch (Throwable e) { |
271 | | - HTTPUnexpectedExceptionHandler unexpectedExceptionHandler = configuration.getDefaultExceptionHandler(); |
272 | 270 | var status = Status.InternalServerError; |
273 | | - if (unexpectedExceptionHandler != null) { |
274 | | - if (response != null) { |
275 | | - // Set the initial status, allowing the handler to attempt to modify the status code. |
276 | | - response.setHeader(Headers.Connection, Connections.Close); |
277 | | - response.setStatus(status); |
278 | | - } |
279 | | - |
280 | | - try { |
281 | | - unexpectedExceptionHandler.handle(response, e); |
282 | | - } catch (Throwable ignore) { |
283 | | - } |
284 | | - |
285 | | - status = response != null ? response.getStatus() : status; |
286 | | - } else { |
287 | | - // Log the error |
288 | | - logger.error(String.format("[%s] Closing socket with status [%d]. An HTTP worker threw an exception while processing a request.", Thread.currentThread().threadId(), status), e); |
| 271 | + try { |
| 272 | + status = configuration.getUnexpectedExceptionHandler().handle(logger, e); |
| 273 | + } catch (Throwable ignore) { |
289 | 274 | } |
290 | 275 |
|
291 | 276 | // Signal an error |
|
0 commit comments