public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
logger.debug("Error while processing imap request" ,e.getCause());
// logout on error not sure if that is the best way to handle it
final ImapSession imapSession = (ImapSessionImpl) getAttachment(ctx).get(IMAP_SESSION);
if (imapSession != null) imapSession.logout();
// just close the channel now!
ctx.getChannel().close();
super.exceptionCaught(ctx, e);