def get_task_error_message(task_result):
    """
    Parse error message from task result.
    """
    try:
        res = task_result['result']
    except Exception:
        res = task_result

    for key in ('detail', 'message'):
        try:
            return res[key]
        except Exception:
            continue

    return str(res)