catch uncaught (in promise)
See original GitHub issueThe async function to handle init event cannot catch promise rejection error inside try - catch block. Seems like the reject method was not implemented in promise object passed. I used the sample in its doc as:
methods: {
async onInit (promise) {
// show loading indicator
try {
await promise
// successfully initialized
} catch (error) {
if (error.name === 'NotAllowedError') {
// user denied camera access permisson
} else if (error.name === 'NotFoundError') {
// no suitable camera device installed
} else if (error.name === 'NotSupportedError') {
// page is not served over HTTPS (or localhost)
} else if (error.name === 'NotReadableError') {
// maybe camera is already in use
} else if (error.name === 'OverconstrainedError') {
// passed constraints don't match any camera. Did you requested the front camera although there is none?
} else {
// browser is probably lacking features (WebRTC, Canvas)
}
} finally {
// hide loading indicator
}
}
}
I get the console error in chrome:
Uncaught (in promise) vue-qrcode-reader.common.js?1730:1
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:13 (4 by maintainers)
Top Results From Across the Web
How to catch uncaught exception in Promise - Stack Overflow
The Golden Rule of done vs. then usage is: either return your promise to someone else, or if the chain ends with you,...
Read more >Error handling with promises - The Modern JavaScript Tutorial
The "invisible try..catch " around the executor automatically catches the error and turns it into rejected promise. This happens not only in the ......
Read more >Promise.prototype.catch() - JavaScript - MDN Web Docs
The catch() method of a Promise object schedules a function to be called when the promise is rejected. It immediately returns an equivalent ......
Read more >Promises - Error Handling - Beginner JavaScript - Wes Bos
The way you catch an error in a promise is you chain a .catch() to it. Catch will pass you the ... catching...
Read more >Promise Error Handling - JavaScript Tutorial
Inside the promise, the catch() method will catch the error caused by the throw statement and reject() . · If an error occurs...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I see! Haha 😁 don’t worry.
FYI you can also simply write
<QrcodeReader @init="onInit($event)" />
if you find this more convenient.Wow I didn’t know that! Thanks for the helpful tip & support. +1