@Override
 public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
   if (cause instanceof IOException) {
     if (LOGGER.isDebugEnabled()) {
       LOGGER.debug(
           logIdent(ctx, endpoint) + "Connection reset by peer: " + cause.getMessage(), cause);
     } else {
       LOGGER.info(logIdent(ctx, endpoint) + "Connection reset by peer: " + cause.getMessage());
     }
     handleOutstandingOperations(ctx);
   } else if (cause instanceof DecoderException
       && cause.getCause() instanceof SSLHandshakeException) {
     if (!connectFuture.isDone()) {
       connectFuture.setFailure(cause.getCause());
     } else {
       // This should not be possible, since handshake is done before connecting. But just in case,
       // we
       // can trap and log an error that might slip through for one reason or another.
       LOGGER.warn(
           logIdent(ctx, endpoint)
               + "Caught SSL exception after being connected: "
               + cause.getMessage(),
           cause);
     }
   } else {
     LOGGER.warn(
         logIdent(ctx, endpoint) + "Caught unknown exception: " + cause.getMessage(), cause);
     ctx.fireExceptionCaught(cause);
   }
 }