예제 #1
0
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
   if (e.getCause() instanceof JsonParseException) {
     BaseTransport.respond(
         e.getChannel(), HttpResponseStatus.INTERNAL_SERVER_ERROR, "Broken JSON encoding.");
   } else if (e.getCause() instanceof SessionHandler.NotFoundException) {
     BaseTransport.respond(
         e.getChannel(),
         HttpResponseStatus.NOT_FOUND,
         "Session not found. Cannot send data to non-existing session.");
   } else {
     super.exceptionCaught(ctx, e);
   }
 }
  @Override
  public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
    Channel ch = e.getChannel();
    Throwable cause = e.getCause();
    if (cause instanceof TooLongFrameException) {
      sendError(ctx, BAD_REQUEST);
      return;
    }

    cause.printStackTrace();
    if (ch.isConnected()) {
      sendError(ctx, INTERNAL_SERVER_ERROR);
    }
  }