Prints an agent error and exits

def agent_error(e: requests.HTTPError, fatal=True):
    """
    Prints an agent error and exits
    """
    try:
        data = e.response.json()
        details = data['detail']  # type: str
    except JSONDecodeError:
        details = e.response.text or str(e.response)

    lines = ('[AGENT] {}'.format(line) for line in details.splitlines())
    msg = '\n' + '\n'.join(lines)

    if fatal:
        fatal_error(msg)
    else:
        error(msg)