diff --git a/src/main/java/io/sinistral/proteus/server/Extractors.java b/src/main/java/io/sinistral/proteus/server/Extractors.java index b6543b5..8b92683 100644 --- a/src/main/java/io/sinistral/proteus/server/Extractors.java +++ b/src/main/java/io/sinistral/proteus/server/Extractors.java @@ -104,7 +104,7 @@ public static java.util.Optional jsonModel(final HttpServerExchange exch return OBJECT_MAPPER.readValue(b, type); } catch (Exception e) { - //log.error(e.getMessage(),e); + log.error(e.getMessage(),e); return null; } }); @@ -118,7 +118,7 @@ public static java.util.Optional jsonModel(final HttpServerExchange exch return OBJECT_MAPPER.readValue(b, type); } catch (Exception e) { - //log.error(e.getMessage(),e); + log.error(e.getMessage(),e); return null; } }); @@ -132,7 +132,7 @@ public static java.util.Optional xmlModel(final HttpServerExchange excha return XML_MAPPER.readValue(b,XML_MAPPER.getTypeFactory().constructType(type.getType())); } catch (Exception e) { - //log.error(e.getMessage(),e); + log.error(e.getMessage(),e); return null; } }); @@ -146,7 +146,7 @@ public static java.util.Optional xmlModel(final HttpServerExchange excha return XML_MAPPER.readValue(b,type); } catch (Exception e) { - //log.error(e.getMessage(),e); + log.error(e.getMessage(),e); return null; } }); diff --git a/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java b/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java index bff3542..3524c3e 100644 --- a/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java +++ b/src/main/java/io/sinistral/proteus/server/handlers/ServerDefaultResponseListener.java @@ -3,6 +3,8 @@ */ package io.sinistral.proteus.server.handlers; +import java.io.PrintWriter; +import java.io.StringWriter; import java.util.HashMap; import java.util.Map; @@ -57,14 +59,23 @@ public boolean handleDefaultResponse(HttpServerExchange exchange) Map errorMap = new HashMap<>(); + errorMap.put("exceptionClass", throwable.getClass().getName()); + errorMap.put("message", throwable.getMessage()); - + if( throwable.getStackTrace() != null ) { if( throwable.getStackTrace().length > 0 ) { - errorMap.put("exceptionClass", throwable.getStackTrace()[0].getClassName()); + errorMap.put("className", throwable.getStackTrace()[0].getClassName()); } + + StringWriter sw = new StringWriter(); + throwable.printStackTrace(new PrintWriter(sw)); + String exceptionAsString = sw.toString(); + + errorMap.put("stackTrace", exceptionAsString); + } if(throwable instanceof IllegalArgumentException )