We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a100a28 commit 77000bbCopy full SHA for 77000bb
example-app/src/pages/Home.tsx
@@ -7,10 +7,18 @@ const Home: React.FC = () => {
7
const [scannerResult, setScannerResult] = useState<string>('No Data...');
8
9
const scanBarcode = async () => {
10
- const result = await CapacitorBarcodeScanner.scanBarcode({
11
- hint: CapacitorBarcodeScannerTypeHint.ALL
12
- });
13
- setScannerResult(result.ScanResult);
+ try {
+ const result = await CapacitorBarcodeScanner.scanBarcode({
+ hint: CapacitorBarcodeScannerTypeHint.ALL
+ });
14
+ setScannerResult(result.ScanResult);
15
+ } catch (error) {
16
+ if (error instanceof Error) {
17
+ setScannerResult("Error: " + error.message);
18
+ } else {
19
+ setScannerResult("Error: Unknown error");
20
+ }
21
22
};
23
24
return (
0 commit comments