handle exceptions by throwing, not with results

This commit is contained in:
2025-10-25 21:02:22 +02:00
parent d855ca4ea4
commit 1bcc5df822
5 changed files with 66 additions and 180 deletions

View File

@@ -60,17 +60,11 @@ class _SheetViewerPageState extends State<SheetViewerPage>
Future<bool> loadPdf() async {
if (kIsWeb) {
var data = await widget.apiClient.fetchPdfFileData(widget.sheet.uuid);
if (data == null) {
throw Exception("Failed fetching pdf file");
}
final data = await widget.apiClient.fetchPdfFileData(widget.sheet.uuid);
document = await PdfDocument.openData(data);
} else {
var file = await widget.apiClient.getPdfFileCached(widget.sheet.uuid);
if (file == null) {
throw Exception("Failed fetching pdf file");
}
final file = await widget.apiClient.getPdfFileCached(widget.sheet.uuid);
document = await PdfDocument.openFile(file.path);
}
@@ -181,6 +175,7 @@ class _SheetViewerPageState extends State<SheetViewerPage>
],
);
} else if (snapshot.hasError) {
log.warning("Error loading pdf:", snapshot.error);
return Center(
child: Text(
style: Theme.of(