cannot catch all error in promise chain
See original GitHub issuemy test code, just simple visit a host which not exist.
const download = require('download');
download('https://www.ahostnotexisttddddd.com.hk', {
timeout: 100
}).then(result => {
console.log(result);
}).catch(() => {
console.error('error catched!')
});
out put is
error catched!
events.js:183
throw er; // Unhandled 'error' event
^
RequestError: Request timed out
at Timeout.setTimeout [as _onTimeout] (/user/test/test/node_modules/got/index.js:205:24)
at ontimeout (timers.js:475:11)
at tryOnTimeout (timers.js:310:5)
at Timer.listOnTimeout (timers.js:270:5)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:5
Top Results From Across the Web
Why catch at the end of promise chain is not ... - Stack Overflow
Now when i call the chain, it only works in case when inBlacklist was rejected. For the others it appears as an unhandled...
Read more >Error handling with promises - The Modern JavaScript Tutorial
Promise chains are great at error handling. ... The easiest way to catch all errors is to append .catch to the end of...
Read more >Promise.prototype.catch() - JavaScript - MDN Web Docs
The catch method is used for error handling in promise composition. Since it returns a Promise , it can be chained in the...
Read more >Catching and handling different types of errors in promise chains
Promise.reject to throw specified errors ... Here's where it all comes together. Both API calls have their own .catch . This way, we...
Read more >Error handling in long Promise chains | by Arthur Xavier
.catch(setErrorState);. Where all the functions on the Promise chain such as uploadImage, saveService, etc. are functions that return a ...
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 FreeTop 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
Top GitHub Comments
same question here
You can do this ugly workarround
eddited for better manage inside of a promisechain
It is very ugly but does the job. I think that the GOT package errors are not handled properly