handle exceptions by throwing, not with results
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user