29 lines
934 B
Python
29 lines
934 B
Python
from core.runtime.outputs import buildOutput
|
|
from core.execution.action.action import buildAction
|
|
#from core.runtime.outputs import buildOutput
|
|
|
|
def manageFailure(error, action, outputs):
|
|
if hasattr(action, "recoverPolicy"):
|
|
errors = action.recoverPolicy
|
|
error_type = type(error)
|
|
|
|
#print(f"{type(error).__name__} detected during {action.name}. Applying recovery policy.")
|
|
|
|
if error_type in errors:
|
|
repairs = errors[error_type]
|
|
|
|
for repair in repairs:
|
|
if repair == False:
|
|
return False
|
|
|
|
elif repair is None:
|
|
return
|
|
|
|
else:
|
|
print(f"{type(error).__name__} detected during {action.name}. Applying recovery policy.")
|
|
|
|
outputs, response = buildAction(repair, outputs)
|
|
|
|
return outputs
|
|
print(f"{error}")
|