Skip to content

Commit 99e964b

Browse files
-refactor: add catch after use promise
1 parent 2f321fc commit 99e964b

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

  • BarcodeReaderSimpleSample

BarcodeReaderSimpleSample/App.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,31 +60,32 @@ const useImagePicker = (imagePickerLauncher, setModalState) => {
6060
return false;
6161
}
6262
setModalState({isVisible: true, text: 'decoding...'});
63-
decodeFile(res.assets[0].uri.split('file://')[1]).then(
64-
results => {
63+
decodeFile(res.assets[0].uri.split('file://')[1])
64+
.then(results => {
6565
let str = mergeResultsText(results);
6666
setModalState({isVisible: true, text: str});
67-
},
68-
err => {
69-
setModalState({isVisible: true, text: err});
70-
},
71-
);
67+
})
68+
.catch(err => {
69+
setModalState({isVisible: true, text: err.toString()});
70+
});
7271
});
7372
};
7473

7574
(async () => {
7675
// Initialize the license so that you can use full feature of the Barcode Reader module.
76+
await DCVBarcodeReader.initLicense(
77+
'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9',
78+
).catch(e => {
79+
console.log(e);
80+
});
7781
try {
78-
await DCVBarcodeReader.initLicense(
79-
'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9',
82+
this.dbr = await DCVBarcodeReader.createInstance();
83+
await this.dbr.updateRuntimeSettings(
84+
EnumDBRPresetTemplate.IMAGE_READ_RATE_FIRST,
8085
);
8186
} catch (e) {
8287
console.log(e);
8388
}
84-
this.dbr = await DCVBarcodeReader.createInstance();
85-
await this.dbr.updateRuntimeSettings(
86-
EnumDBRPresetTemplate.IMAGE_READ_RATE_FIRST,
87-
);
8889
})();
8990

9091
const modalInitState = {

0 commit comments

Comments
 (0)