/** {@inheritDoc} */
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
Throwable th = e.getCause();
NettyTcpResponse response = new NettyTcpResponse(e.getChannel());
if (th instanceof ClosedChannelException) {
// never reply in case of channel closed exception
return;
}
if (th instanceof java.io.IOException) {
LOGGER.info(th); // regular disconnect causes this expected exception
return;
} else {
LOGGER.error("Responder error", th);
}
if (th instanceof HasFaultResponseException) {
((HasFaultResponseException) th).setFaultResponse(response);
response.write();
return;
}
SCMPMessageFault fault = new SCMPMessageFault(SCMPVersion.LOWEST, SCMPError.SC_ERROR, th.getMessage()
+ " caught exception in web responder request handler");
fault.setMessageType(SCMPMsgType.UNDEFINED);
response.setSCMP(fault);
response.write();
}