public static void handleError(HttpExchangeImpl x, Throwable e) {
Throwable cause = UTILS.rootCause(e);
if (cause instanceof HttpSuccessException) {
x.completeResponse();
} else if (cause instanceof HttpNotFoundException) {
if (!x.uri().equals("/favicon.ico") && !x.uri().endsWith(".js.map")) {
Log.warn("HTTP resource not found!", "app", AppCtx.app().getId(), "uri", x.uri());
}
x.completeResponse();
} else if (cause instanceof CancellationException) {
Log.error("Thread interruption, probably timeout!", "request", x, "error", cause);
x.response(500, "Request timeout!", null);
} else if (cause instanceof ThreadDeath) {
Log.error("Thread death, probably timeout!", "request", x, "error", cause);
x.response(500, "Request timeout!", null);
} else {
Log.error("Internal server error!", "request", x, "error", cause);
x.error(e);
x.completeResponse();
}
x.done();
}