Refactor envelope processing for per-item error handling
Move per-envelope logic in FinalizeDocumentJob into its own try-catch block within the foreach loop. This ensures that exceptions in processing one envelope do not halt the processing of others, improving robustness and fault tolerance. Removed the outer try-catch-finally block and updated logging to reflect per-envelope and overall job status.
This commit is contained in:
@@ -43,8 +43,6 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
|
||||
var jobId = typeof(FinalizeDocumentJob).FullName;
|
||||
logger.LogDebug("Starting job {jobId}", jobId);
|
||||
|
||||
try
|
||||
{
|
||||
_config = await mediator.Send(new ReadDefaultConfigQuery(), cancel);
|
||||
|
||||
var envelopes = await envRepo
|
||||
@@ -145,26 +143,6 @@ public class FinalizeDocumentJob(IOptions<WorkerOptions> options, IConfiguration
|
||||
|
||||
logger.LogDebug("Completed job {jobId} successfully!", jobId);
|
||||
}
|
||||
catch (MergeDocumentException ex)
|
||||
{
|
||||
logger.LogWarning("Certificate Document job failed at step: Merging documents!");
|
||||
logger.LogError(ex);
|
||||
}
|
||||
catch (ExportDocumentException ex)
|
||||
{
|
||||
logger.LogWarning("Certificate Document job failed at step: Exporting document!");
|
||||
logger.LogError(ex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogWarning("Certificate Document job failed!");
|
||||
logger.LogError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
logger.LogDebug("Job execution for [{jobId}] ended", jobId);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateFileDb(string filePath, long envelopeId)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user