@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
Channel channel = ctx.getChannel();
ProtocolSession session = (ProtocolSession) ctx.getAttachment();
if (e.getCause() instanceof TooLongFrameException) {
Response r = session.newLineTooLongResponse();
ProtocolTransport transport = ((AbstractSession)session).getProtocolTransport();
if (r != null) {
transport.writeResponse(r, session);
}
} else {
if (channel.isConnected()) {
ProtocolTransport transport = ((AbstractSession)session).getProtocolTransport();
Response r = session.newFatalErrorResponse();
if (r != null) {
transport.writeResponse(r, session);
}
transport.writeResponse(Response.DISCONNECT, session);
}