paillave / Etl.Net

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

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

Open mickvikt opened 10 months ago

mickvikt commented 10 months 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 10 months 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");