How to use `DagsterUserCodeExecutionError`
# ask-ai
d
How to use
DagsterUserCodeExecutionError
s
The
DagsterUserCodeExecutionError
is a base class for exceptions that are meant to wrap an exception thrown by user code during the execution of a Dagster pipeline. This error class is used by the framework to catch exceptions that occur in user code and rethrow them with additional context provided by the Dagster runtime. According to the documentation, users should not subclass
DagsterUserCodeExecutionError
for their own exceptions. Instead, they should throw exceptions freely from their user code, and Dagster will automatically wrap and rethrow these exceptions as
DagsterUserCodeExecutionError
instances. Here's an example of how
DagsterUserCodeExecutionError
might be used within the framework:
Copy code
python with user_code_error_boundary(     DagsterExecutionStepExecutionError,     "Error occurred during step execution" ):     call_user_provided_function()
In this example,
user_code_error_boundary
is a context manager that wraps the execution of
call_user_provided_function()
. If an exception occurs within this function, it will be caught and rethrown as a
DagsterExecutionStepExecutionError
, which is a subclass of
DagsterUserCodeExecutionError
. The message "Error occurred during step execution" provides additional context about where the error occurred. As a user, you generally do not need to directly use
DagsterUserCodeExecutionError
. Instead, you should focus on writing your business logic and let Dagster handle the error wrapping. If you encounter this error while running your pipeline, it indicates that an exception has occurred in your user code, and you should inspect the original exception and stack trace to debug the issue.