Refactor error handling in DocumentService and consumers

Refactored `DocumentService.GetDocumentAsync` to throw
`HttpRequestException` on failure instead of returning a tuple.
Updated all consumers to handle exceptions, improving error
handling consistency across the application.

Enhanced error messages for better user feedback and added
logging for improved traceability. Updated `EnvelopeReceiverPage`,
`EnvelopeReceiverPage_DxReportViewer`, and `ReportViewer` to
use the new exception-based API and handle errors gracefully.

This change simplifies the API, improves maintainability, and
makes the application more robust and user-friendly.
This commit is contained in:
2026-06-11 13:33:15 +02:00
parent ecb7f45f14
commit cf16312394
4 changed files with 35 additions and 14 deletions

View File

@@ -346,9 +346,14 @@ Shown="OnPopupShownAsync">
_envelopeReceiver = await EnvelopeReceiverService.GetAsync(EnvelopeKey ?? "fake");
if (!AppOptions.Value.UsePredefinedReports && !string.IsNullOrWhiteSpace(EnvelopeKey)) {
var (pdfBytes, _) = await DocumentService.GetDocumentAsync(EnvelopeKey);
if (pdfBytes is { Length: > 0 })
_basePdfBytes = pdfBytes;
try {
var pdfBytes = await DocumentService.GetDocumentAsync(EnvelopeKey);
if (pdfBytes is { Length: > 0 })
_basePdfBytes = pdfBytes;
} catch (HttpRequestException ex) {
// Log error but continue - will use predefined report instead
Console.WriteLine($"Failed to load document: {ex.Message}");
}
}
var initialReport = BuildFreshBaseReport();