def __init__(self, requests_exception):
        self.status_code = requests_exception.response.status_code
        self.HTTPError = requests_exception
        content_type = requests_exception.response.headers['content-type']
        if 'json' in content_type:
            content = requests_exception.response.content
            if content != '':
                res_payload = json.loads(
                    requests_exception.response.content.decode('utf8')
                )
                if 'detail' in res_payload:
                    self.message = res_payload['detail']
                else:
                    self.message = ''
            else:
                self.message = ''
        elif content_type == 'text/plain':
            self.message = requests_exception.response.content
        else:
            try:
                self.message = requests_exception.message
            except AttributeError:
                self.message = 'unknown error'
dataset/ETHPy150Open plotly/plotly.py/plotly/exceptions.py/PlotlyRequestError.__init__/original