Skip to content

Commit 09a6ea8

Browse files
committed
fix 'Failed to connect to Dynamsoft...' always shows when any error throws
1 parent 9153ad7 commit 09a6ea8

File tree

33 files changed

+281
-200
lines changed

33 files changed

+281
-200
lines changed

1.hello-world/1.hello-world.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@
5555
*/
5656
await scanner.show();
5757
} catch (ex) {
58-
if (ex.message.indexOf("network connection error")) {
59-
let customMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
60-
console.log(customMsg);
61-
alert(customMsg);
58+
let errMsg;
59+
if (ex.message.includes("network connection error")) {
60+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
61+
} else {
62+
errMsg = ex.message||ex;
6263
}
63-
throw ex;
64+
console.error(errMsg);
65+
alert(errMsg);
6466
}
6567
})();
6668
</script>

1.hello-world/10.read-video-pwa/helloworld-pwa.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ <h1 style="font-size: 1.5em;">Hello World for PWA</h1>
6464
}
6565
await scanner.show();
6666
} catch (ex) {
67-
if (ex.message.indexOf("network connection error")) {
68-
let customMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
69-
console.log(customMsg);
70-
alert(customMsg);
67+
let errMsg;
68+
if (ex.message.includes("network connection error")) {
69+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
70+
} else {
71+
errMsg = ex.message||ex;
7172
}
72-
throw ex;
73+
console.error(errMsg);
74+
alert(errMsg);
7375
}
7476
})();
7577

1.hello-world/11.read-video-requirejs.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ <h1 style="font-size: 1.5em;">Hello World for RequireJS</h1>
4747
}
4848
await scanner.show();
4949
} catch (ex) {
50-
if (ex.message.indexOf("network connection error")) {
51-
let customMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
52-
console.log(customMsg);
53-
alert(customMsg);
50+
let errMsg;
51+
if (ex.message.includes("network connection error")) {
52+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
53+
} else {
54+
errMsg = ex.message||ex;
5455
}
55-
throw ex;
56+
console.error(errMsg);
57+
alert(errMsg);
5658
}
5759
})();
5860
})

1.hello-world/12.read-video-es6.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ <h1 style="font-size: 1.5em;">Hello World for ES6</h1>
5454
}
5555
await scanner.show();
5656
} catch (ex) {
57-
if (ex.message.indexOf("network connection error")) {
58-
let customMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
59-
console.log(customMsg);
60-
alert(customMsg);
57+
let errMsg;
58+
if (ex.message.includes("network connection error")) {
59+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
60+
} else {
61+
errMsg = ex.message||ex;
6162
}
62-
throw ex;
63+
console.error(errMsg);
64+
alert(errMsg);
6365
}
6466
})();
6567
</script>

1.hello-world/2.read-an-image.html

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
5656
} catch (ex) {
5757
document.getElementById('p-loading').innerText = ex;
5858
document.getElementById('ipt-file').disabled = true;
59-
if (ex.message.indexOf("network connection error")) {
60-
let customMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
61-
console.log(customMsg);
62-
alert(customMsg);
59+
let errMsg;
60+
if (ex.message.includes("network connection error")) {
61+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
62+
} else {
63+
errMsg = ex.message||ex;
6364
}
64-
throw ex;
65+
console.error(errMsg);
66+
alert(errMsg);
6567
}
6668
})();
6769

@@ -105,12 +107,14 @@ <h1 style="font-size: 1.5em;">Read Barcode from Images</h1>
105107
divResults.appendChild(document.createElement('hr'));
106108
divResults.scrollTop = divResults.scrollHeight;
107109
} catch (ex) {
108-
if (ex.message.indexOf("network connection error")) {
109-
let customMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
110-
console.log(customMsg);
111-
alert(customMsg);
110+
let errMsg;
111+
if (ex.message.includes("network connection error")) {
112+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
113+
} else {
114+
errMsg = ex.message||ex;
112115
}
113-
throw ex;
116+
console.error(errMsg);
117+
alert(errMsg);
114118
} finally {
115119
pReading.style.display = 'none';
116120
this.value = '';

1.hello-world/3.read-video-angular/src/app/barcode-scanner/barcode-scanner.component.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ export class VideoDecodeComponent implements OnInit {
2222
};
2323
await scanner.open();
2424
} catch (ex) {
25-
if (ex.message.indexOf("network connection error")) {
26-
let customMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
27-
console.log(customMsg);
28-
alert(customMsg);
25+
let errMsg;
26+
if (ex.message.includes("network connection error")) {
27+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
28+
} else {
29+
errMsg = ex.message||ex;
2930
}
31+
console.error(errMsg);
32+
alert(errMsg);
3033
}
3134
}
3235
async ngOnDestroy() {

1.hello-world/3.read-video-angular/src/app/hello-world/hello-world.component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ export class HelloWorldComponent implements OnInit {
1515
try {
1616
await BarcodeScanner.loadWasm();
1717
} catch (ex) {
18-
if (ex.message.indexOf("network connection error")) {
19-
let customMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
20-
console.log(customMsg);
21-
alert(customMsg);
18+
let errMsg;
19+
if (ex.message.includes("network connection error")) {
20+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
21+
} else {
22+
errMsg = ex.message||ex;
2223
}
23-
throw ex;
24+
console.error(errMsg);
25+
alert(errMsg);
2426
}
2527
}
2628
showScanner(): void {

1.hello-world/3.read-video-angular/src/app/img-decode/img-decode.component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ export class ImgDecodeComponent implements OnInit {
2020
}
2121
if (!results.length) { alert('No barcode found'); }
2222
} catch (ex) {
23-
if (ex.message.indexOf("network connection error")) {
24-
let customMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
25-
console.log(customMsg);
26-
alert(customMsg);
23+
let errMsg;
24+
if (ex.message.includes("network connection error")) {
25+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
26+
} else {
27+
errMsg = ex.message||ex;
2728
}
28-
throw ex;
29+
console.error(errMsg);
30+
alert(errMsg);
2931
}
3032
e.target.value = '';
3133
}

1.hello-world/4.read-video-react/src/components/HelloWorld/HelloWorld.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ class HelloWorld extends React.Component {
1818
try {
1919
await BarcodeReader.loadWasm();
2020
} catch (ex) {
21-
if (ex.message.indexOf("network connection error")) {
22-
let customMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
23-
console.log(customMsg);
24-
alert(customMsg);
21+
let errMsg;
22+
if (ex.message.includes("network connection error")) {
23+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
24+
} else {
25+
errMsg = ex.message||ex;
2526
}
26-
throw ex;
27+
console.error(errMsg);
28+
alert(errMsg);
2729
}
2830
}
2931

1.hello-world/4.read-video-react/src/components/ImgDecode/ImgDecode.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ export default class ImgDecode extends Component {
1717
}
1818
if (!results.length) { alert('No barcode found'); }
1919
} catch (ex) {
20-
if (ex.message.indexOf("network connection error")) {
21-
let customMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
22-
console.log(customMsg);
23-
alert(customMsg);
20+
let errMsg;
21+
if (ex.message.includes("network connection error")) {
22+
errMsg = "Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
23+
} else {
24+
errMsg = ex.message||ex;
2425
}
25-
throw ex;
26+
console.error(errMsg);
27+
alert(errMsg);
2628
}
2729
e.target.value = '';
2830
}

0 commit comments

Comments
 (0)