public void exceptionCaught(ChannelHandlerContext ctx, Throwable t) { if (t instanceof ClosedChannelException) { _logger.info("Connection {} unexpectedly closed.", ctx.channel()); } else if (t instanceof Exception) { for (NettyTransferService<HttpProtocolInfo>.NettyMoverChannel file : _files) { CacheException cause; if (file == _writeChannel) { cause = new FileCorruptedCacheException("Connection lost before end of file: " + t, t); } else { cause = new CacheException(t.toString(), t); } file.release(cause); } _files.clear(); ctx.close(); } else { Thread me = Thread.currentThread(); me.getUncaughtExceptionHandler().uncaughtException(me, t); ctx.close(); } }
private void handleDeath(Throwable cause) { if (cause != null) sendHttpResponse( ctx, req, new DefaultFullHttpResponse( req.getProtocolVersion(), INTERNAL_SERVER_ERROR, Unpooled.wrappedBuffer( ("Actor is dead because of " + cause.getMessage()).getBytes())), false); else sendHttpResponse( ctx, req, new DefaultFullHttpResponse( req.getProtocolVersion(), INTERNAL_SERVER_ERROR, Unpooled.wrappedBuffer(("Actor has terminated.").getBytes())), false); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { cause.printStackTrace(); }