@Override
    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
            throws Exception
    {
        Channel ch = e.getChannel();
        Throwable cause = e.getCause();
        if(cause instanceof TooLongFrameException)
        {
            sendErrorResponse(ctx, BAD_REQUEST);
            return;
        }

        cause.printStackTrace();
        if(ch.isConnected())
        {
            sendErrorResponse(ctx, INTERNAL_SERVER_ERROR);
        }
    }