From 6f7b04a26e013930cbe6bf8a1e44ce008b5ab53f Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 9 Mar 2026 16:31:31 +0100 Subject: [PATCH] Refactor: remove strict checks and logging in finalization Removed exception throwing and logging for failed report creation, email sending, and envelope finalization in FinalizeDocumentJob. Now, these methods are called without checking their return values. Also improved exception message for file export to include envelope Id and added null-forgiving operator to _config.ExportPath. --- .../Jobs/FinalizeDocumentJob.cs | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs b/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs index 95693b04..94faa23b 100644 --- a/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs +++ b/EnvelopeGenerator.ServiceHost/Jobs/FinalizeDocumentJob.cs @@ -81,23 +81,18 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration var burnedDocument = pdfBurner!.BurnAnnotsToPDF(envelope.DefaultDocument.ByteData!, annotations, envelope.Id) ?? throw new ApplicationException("Document could not be finalized"); - if (!actionService.CreateReport(envelope, cancel)) - { - logger.LogWarning("Document Report could not be created!"); - throw new ApplicationException("Document Report could not be created"); - } + actionService.CreateReport(envelope, cancel); var report = reportCreator!.CreateReport(envelope); var mergedDocument = pdfMerger!.MergeDocuments(burnedDocument, report); - var outputDirectoryPath = Path.Combine(_config.ExportPath, _parentFolderUid); + var outputDirectoryPath = Path.Combine(_config!.ExportPath, _parentFolderUid); if (!Directory.Exists(outputDirectoryPath)) Directory.CreateDirectory(outputDirectoryPath); var outputFilePath = Path.Combine(outputDirectoryPath, $"{envelope.Uuid}.pdf"); - logger.LogInformation("Output path is [{outputFilePath}]", outputFilePath); try { @@ -105,23 +100,15 @@ public class FinalizeDocumentJob(IOptions options, IConfiguration } catch (Exception ex) { - logger.LogWarning("Could not export final document to disk!"); - throw new ExportDocumentException("Could not export final document to disk!", ex); + throw new ExportDocumentException("Could not export final document to disk. Envelope Id is " + envelope.Id, ex); } var outputFile = await File.ReadAllBytesAsync(outputFilePath, cancel); await envRepo.UpdateAsync(e => e.DocResult = outputFile, e => e.Id == envelope.Id, cancel); - if (!SendFinalEmails(envelope)) - throw new ApplicationException("Final emails could not be sent!"); - - logger.LogInformation("Report-mails successfully sent!"); + SendFinalEmails(envelope); - if (actionService?.FinalizeEnvelope(envelope) == false) - { - logger.LogWarning("Envelope could not be finalized!"); - throw new ApplicationException("Envelope could not be finalized"); - } + actionService?.FinalizeEnvelope(envelope); } private bool SendFinalEmails(Envelope envelope)