From 053a20f2a0689fccb432a0c6d9811fdf75447f48 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 17 Nov 2017 12:27:27 +1000 Subject: [PATCH] Added try/catch block to control barcode substring reading error. --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 2871ad6..665331e 100644 --- a/index.js +++ b/index.js @@ -194,7 +194,12 @@ function PDFDicer() { if (this.range[memBarcodeID] == null) { this.range[memBarcodeID] = new Object(); this.range[memBarcodeID].barcode = new Object(); - this.range[memBarcodeID].barcode.id = page.barcode.substring(page.barcode.lastIndexOf("/") + 1, page.barcode.length); + try { + this.range[memBarcodeID].barcode.id = page.barcode.substring(page.barcode.lastIndexOf("/") + 1, page.barcode.length); + } catch (error) { + // The barcode scanner is not able to find the barcode information. + this.range[memBarcodeID].barcode.id = page.barcode; + } this.range[memBarcodeID].barcode.start = page.barcode; this.range[memBarcodeID].pages = 1; this.range[memBarcodeID].from = index + 1;