mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 03:10:42 -03:30
* Change handling of error cases to global post_run_hook * handle license errors correctly again * Fix some issues with line ordering from the custom logger thing * Remove debug log statement * Use PermissionDenied for license errors * More elegant handling of line initialization Update tests to new exception type Catch all save errors, fix timing offset bug Fix license error handling inside import command
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
# Copyright (c) 2018 Ansible by Red Hat
|
|
# All Rights Reserved.
|
|
|
|
|
|
|
|
class _AwxTaskError():
|
|
def build_exception(self, task, message=None):
|
|
if message is None:
|
|
message = "Execution error running {}".format(task.log_format)
|
|
e = Exception(message)
|
|
e.task = task
|
|
e.is_awx_task_error = True
|
|
return e
|
|
|
|
def TaskCancel(self, task, rc):
|
|
"""Canceled flag caused run_pexpect to kill the job run"""
|
|
message="{} was canceled (rc={})".format(task.log_format, rc)
|
|
e = self.build_exception(task, message)
|
|
e.rc = rc
|
|
e.awx_task_error_type = "TaskCancel"
|
|
return e
|
|
|
|
def TaskError(self, task, rc):
|
|
"""Userspace error (non-zero exit code) in run_pexpect subprocess"""
|
|
message = "{} encountered an error (rc={}), please see task stdout for details.".format(task.log_format, rc)
|
|
e = self.build_exception(task, message)
|
|
e.rc = rc
|
|
e.awx_task_error_type = "TaskError"
|
|
return e
|
|
|
|
|
|
AwxTaskError = _AwxTaskError()
|
|
|
|
|
|
class PostRunError(Exception):
|
|
def __init__(self, msg, status='failed', tb=''):
|
|
self.status = status
|
|
self.tb = tb
|
|
super(PostRunError, self).__init__(msg)
|