Checks for correct data response and status codes

def process_response(self, response: requests.models.Response) -> dict:
        """ Checks for correct data response and status codes """
        try:
            output = response.json()
        except json.JSONDecodeError: # Server is having a bad day and crashed.
            raise self.BadResponseError(
                'Json not returned with status code [' + str(response.status_code) + ']')

        if response.status_code == 400:
            return output

        if response.status_code not in [200, 201]: # Safety catch.
            raise self.BadResponseError(
                str(output) + ': with status code [' + str(response.status_code) +
                '] and params:' + str(output))

        return output['data']