def on_message(self, raw):
        msg = decode_frame(raw)
        if msg.type in (FRAME_ERROR_TYPE, FRAME_RESPONSE_TYPE):
            # did we received an error?
            error = None
            result = None
            if msg.type == FRAME_ERROR_TYPE:
                error = json.loads(msg.body.decode('utf-8'))
                self.close()
            else:
                result = msg.body

            if msg.id == "gaffer_error":
                if self._on_error_cb is not None:
                    return self._async_callback(self._on_error_cb)(self, error)

            # handle message callback if any
            try:
                callback = self.pending.pop(msg.id)
            except __HOLE__:
                return

            self._async_callback(callback)(self, result, error)

        elif msg.type == FRAME_MESSAGE_TYPE:
            if self._read_callback is not None:
                self._async_callback(self._read_callback)(self, msg.body)
dataset/ETHPy150Open benoitc/gaffer/gaffer/httpclient/websocket.py/IOChannel.on_message