def assert_request()

in functions/source/aws_qs_create_org/aws_qs_create_org.py [0:0]


def assert_request(r, msg):
    if r.status_code not in [200, 201]:
        try:
            code = r.json().get('details', [{}])[0].get('error_code')
            details = r.json().get('details', [{}])[0].get('detail', r.text)
        except Exception as e:
            logger.error(e, exc_info=True)
            code, details = ('', r.text)
        raise RuntimeError(f"{msg}: [{r.status_code} {r.reason}] {code} {details}")