Skip to content

Commit

Permalink
More verbose error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Jul 18, 2018
1 parent ec2db6d commit dbcb3ba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/main/java/io/sinistral/proteus/server/Extractors.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static <T> java.util.Optional<T> 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;
}
});
Expand All @@ -118,7 +118,7 @@ public static <T> java.util.Optional<T> 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;
}
});
Expand All @@ -132,7 +132,7 @@ public static <T> java.util.Optional<T> 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;
}
});
Expand All @@ -146,7 +146,7 @@ public static <T> java.util.Optional<T> 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;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -57,14 +59,23 @@ public boolean handleDefaultResponse(HttpServerExchange exchange)

Map<String, String> 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 )
Expand Down

0 comments on commit dbcb3ba

Please sign in to comment.