Improve error handling in FinalizeDocumentJob

Added RethrowOnError property to control exception rethrowing during envelope finalization. Exceptions are now logged as errors and, if RethrowOnError is true, rethrown to enable stricter error handling and halt execution on failure.
This commit is contained in:
2026-03-09 11:30:43 +01:00
parent 7d620988d8
commit a39ef6a0e2

View File

@@ -36,6 +36,8 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
public byte[]? DocAsByte { get; set; }
}
public bool RethrowOnError { get; set; } = true;
public async Task ExecuteAsync(CancellationToken cancel = default)
{
var gdPictureKey = _options.GdPictureLicenseKey;
@@ -63,8 +65,10 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
}
catch (Exception ex)
{
logger.LogError(ex);
logger.LogWarning(ex, "Unhandled exception while working envelope [{id}]", envelope.Id);
logger.LogError(ex, "Unhandled exception while working envelope [{id}]", envelope.Id);
if(RethrowOnError)
throw;
}
logger.LogInformation("Envelope [{id}] finalized!", envelope.Id);