88This module provides a comprehensive exception hierarchy for the workflow system.
99The exceptions are designed to be lightweight while providing sufficient context
1010for error handling and debugging.
11-
12- Classes:
13- BaseError: Base exception class with context support
14- StageError: Exceptions related to stage execution
15- JobError: Exceptions related to job execution
16- WorkflowError: Exceptions related to workflow execution
17- ParamError: Exceptions related to parameter validation
18- ResultError: Exceptions related to result processing
19-
20- Functions:
21- to_dict: Convert exception instances to dictionary format
2211"""
2312from __future__ import annotations
2413
@@ -58,11 +47,13 @@ def to_dict(exception: Exception, **kwargs) -> ErrorData: # pragma: no cov
5847 Example:
5948 >>> try:
6049 >>> raise ValueError("Something went wrong")
61- >>> except Exception as e:
62- >>> error_data = to_dict(e, context="workflow_execution")
63- >>> # Returns: {
64- >>> # "name": "ValueError", "message": "Something went wrong", "context": "workflow_execution"
65- >>> # }
50+ >>> except Exception as err:
51+ >>> error_data = to_dict(err, context="workflow_execution")
52+ {
53+ "name": "ValueError",
54+ "message": "Something went wrong",
55+ "context": "workflow_execution",
56+ }
6657 """
6758 return {
6859 "name" : exception .__class__ .__name__ ,
@@ -71,6 +62,20 @@ def to_dict(exception: Exception, **kwargs) -> ErrorData: # pragma: no cov
7162 }
7263
7364
65+ def mark_errors (context : DictData , error : JobError ) -> None :
66+ """Make the errors context result with the refs value depends on the nested
67+ execute func.
68+
69+ Args:
70+ context (DictData): A context data.
71+ error (JobError): A stage exception object.
72+ """
73+ if "errors" in context :
74+ context ["errors" ][error .refs ] = error .to_dict ()
75+ else :
76+ context ["errors" ] = error .to_dict (with_refs = True )
77+
78+
7479class BaseError (Exception ):
7580 """Base exception class for all workflow-related errors.
7681
0 commit comments