paillave / Etl.Net

Mass processing data with a complete ETL for .net developers
https://paillave.github.io/Etl.Net/
MIT License
674 stars 94 forks source link

Raising an error and short-circuiting the execution of remaining operators #470

Open mickvikt opened 1 year ago

mickvikt commented 1 year ago

In the initial stage of our data processing pipeline, we verify the presence of a predefined set of files. If any of these files are missing, we need to raise an error. Is there a recommended practice for triggering errors, such as invoking a specific method, or is raising an exception the sole approach for handling this situation? Thank you

paillave commented 1 year ago

The way to trigger an error the proper way is to simply raise an exception in the operator where the issue occurs :)

If you want more information about the reason and location of the failure:

var res = await processRunner.ExecuteAsync(args[0], executionOptions);
if (res.ErrorTraceEvent.Content is UnhandledExceptionStreamTraceContent unhandledExceptionStreamTraceContent)
{
    Console.WriteLine($"Error occurred in node {res.ErrorTraceEvent.NodeName}(type {res.ErrorTraceEvent.NodeTypeName}): {unhandledExceptionStreamTraceContent.Message} (exception: {unhandledExceptionStreamTraceContent.Exception})");
}
Console.Write(res.Failed ? "Failed" : "Succeeded");