From aad21cfa3e050d30b8366d2531d88e7762c9e6e8 Mon Sep 17 00:00:00 2001 From: Joshua Bauer Date: Tue, 28 Apr 2020 09:04:11 -0700 Subject: [PATCH] Better error logs. --- CHANGELOG.md | 5 +++++ .../ServerDefaultResponseListener.java | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9c8464..c39a37e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ Proteus Changelog. ## Unreleased ### No issue +**Added multipart/form-data media type.** + + +[544668fabf96683](https://github.com/noboomu/proteus/commit/544668fabf96683) Joshua Bauer *2020-03-30 23:14:29* + **Set version to 4.5 for release** diff --git a/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java b/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java index f0643da..8507dab 100644 --- a/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java +++ b/proteus-core/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java @@ -72,17 +72,24 @@ public boolean handleDefaultResponse(HttpServerExchange exchange) { ServerException serverException = (ServerException) throwable; exchange.setStatusCode(serverException.getStatus()); - statusCode = serverException.getStatus(); + + + } else if (throwable instanceof IllegalArgumentException) { + exchange.setStatusCode(StatusCodes.BAD_REQUEST); } + + errorMap.put("exceptionClass", throwable.getClass().getName()); errorMap.put("message", throwable.getMessage()); errorMap.put("path", path); - errorMap.put("code", Integer.toString(statusCode)); + errorMap.put("code", Integer.toString(exchange.getStatusCode())); - log.error("\n\tmessage: " + throwable.getMessage() + "\n\tpath: " + path, throwable); - if (throwable.getStackTrace() != null) { + if (throwable.getStackTrace() != null && exchange.getStatusCode() >= 500 ) { + + log.error("path: " + path, throwable); + if (throwable.getStackTrace().length > 0) { errorMap.put("className", throwable.getStackTrace()[0].getClassName()); } @@ -101,9 +108,7 @@ public boolean handleDefaultResponse(HttpServerExchange exchange) } } - if (throwable instanceof IllegalArgumentException) { - exchange.setStatusCode(StatusCodes.BAD_REQUEST); - } + if (ServerPredicates.ACCEPT_XML_EXCLUSIVE_PREDICATE.resolve(exchange)) { try {