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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user