From 2fd74098048667ccf90402b7e9e7b9517c6d8aaf Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 29 Jun 2021 22:27:09 +1000 Subject: [PATCH] Throw assertion errors which will be sent to sentry --- lib/barcode.dart | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/barcode.dart b/lib/barcode.dart index ced482e3..2f7a79ea 100644 --- a/lib/barcode.dart +++ b/lib/barcode.dart @@ -247,7 +247,11 @@ class StockItemBarcodeAssignmentHandler extends BarcodeHandler { final InvenTreeStockItem item; - StockItemBarcodeAssignmentHandler(this.item); + StockItemBarcodeAssignmentHandler(this.item) { + if (item == null) { + throw new AssertionError("null StockItem passed to barcode handler"); + } + } @override String getOverlayText(BuildContext context) => L10().barcodeScanAssign; @@ -322,7 +326,11 @@ class StockItemScanIntoLocationHandler extends BarcodeHandler { final InvenTreeStockItem item; - StockItemScanIntoLocationHandler(this.item); + StockItemScanIntoLocationHandler(this.item) { + if (item == null) { + throw new AssertionError("null StockItem passed to StockItemScanIntoLocationHandler"); + } + } @override String getOverlayText(BuildContext context) => L10().barcodeScanLocation; @@ -378,7 +386,11 @@ class StockLocationScanInItemsHandler extends BarcodeHandler { final InvenTreeStockLocation location; - StockLocationScanInItemsHandler(this.location); + StockLocationScanInItemsHandler(this.location) { + if (location == null) { + throw new AssertionError("null StockLocation passed to StockLocationScanInItemsHandler"); + } + } @override String getOverlayText(BuildContext context) => L10().barcodeScanItem;