static ChannelError fromOpenError(int flag, int ctype, ByteBuffer data) {
        int code = flag;
        String message = "";

        if (code < 7) {
            message = "Not allowed to open channel";
        }

        if (ctype == ContentType.UTF8 && data != null) {

            Charset charset = Charset.forName("UTF-8");
            CharsetDecoder decoder = charset.newDecoder();
            int pos = data.position();

            try {
                message = decoder.decode(data).toString();
            } catch (CharacterCodingException ex) {
            } finally {
                data.position(pos);
            }
        }

        return new ChannelError(message, flag);
    }