List of usage examples for io.netty.util.internal ThrowableUtil stackTraceToString
public static String stackTraceToString(Throwable cause)
From source file:org.restnext.server.ServerHandler.java
License:Apache License
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { if (ctx.channel().isActive()) { // Create the response status error. Response.Status status = cause instanceof ServerException ? ((ServerException) cause).getResponseStatus() : INTERNAL_SERVER_ERROR; // Create the response error body. String newLine = "\r\n"; StringJoiner content = new StringJoiner(newLine); content.add("statusCode: " + status.getStatusCode()); content.add("statusMessage: " + status.getReasonPhrase()); content.add("statusFamily: " + status.getFamily()); if (cause.getMessage() != null) { content.add("errorMessage: " + cause.getMessage()); }/*from w w w . jav a 2s . c om*/ if (cause.getCause() != null) { content.add("detailErrorMessage: " + cause.getCause().getMessage()); } content.add("stackTraceMessage: " + ThrowableUtil.stackTraceToString(cause)); // Write the response error. write(ctx, Response.status(status).content(content.toString()).type(MediaType.TEXT_UTF8).build(), false); } ctx.close(); }