perago.result_for_exception#
- perago.result_for_exception(exc)[源代码]#
Classify an exception into a worker attempt result.
The runtime uses this classifier around task invocation and publication so that exceptions are reported through a single Conductor result contract.
- Parameters:
- excException
Exception raised while validating input, running the task body, checking guardrails, staging workspace changes, publishing, or cleaning up an attempt.
- Returns:
- RuntimeTaskResult
FAILED_WITH_TERMINAL_ERRORfor pre guardrail failures andFAILEDfor all other exceptions.
- 参数:
exc (Exception)
- 返回类型:
参见
RuntimeTaskResultValidated result model returned by this function.
PreGuardrailViolationException mapped to terminal failure.
failed_resultBuilder used for ordinary failed results.
terminal_failed_resultBuilder used for terminal failed results.
Notes
The classifier is intentionally fail-closed. Publish fence errors, stale attempts, post guardrail failures, and user task exceptions are not converted into successful results.
Examples
>>> result_for_exception(PreGuardrailViolation("missing raw file")).status 'FAILED_WITH_TERMINAL_ERROR' >>> result_for_exception(RuntimeError("body failed")).status 'FAILED'