@staticmethod
    def build_exception(exc):
        code = exc.response.status_code if hasattr(exc, 'response') else 500
        message = exc.message if hasattr(exc, 'message') else 'Unknown error'
        try:
            json_content = json.loads(exc.content)
        except ValueError:
            pass
        else:
            # Loading the content to json succeeded, try to get the
            # code/message from there
            if 'message' in json_content:
                message = json_content['message']
            elif 'error_message' in json_content:
                message = json_content['error_message']
            if 'code' in json_content:
                code = json_content['code']
            elif json_content in 'error_code':
                code = json_content['error_code']

        exceptions = {
            400: MisfitBadRequest,
            401: MisfitUnauthorized,
            403: MisfitForbidden,
            404: MisfitNotFoundError,
            429: MisfitRateLimitError,
            500: MisfitUnknownError,
            502: MisfitBadGateway
        }
        raise exceptions[code](code, message, getattr(exc, 'response', None))
dataset/ETHPy150Open orcasgit/python-misfit/misfit/exceptions.py/MisfitHttpException.build_exception/swapped operands of `in`