3 ms·
Gosh, adding a `.catch(console.log.bind(console))` is just insane. If you have a library that will return non operational error, just remove it from your proje
by neumino 11y ago
Gosh, adding a `.catch(console.log.bind(console))` is just insane.
If you have a library that will return non operational error, just remove it from your project. If your code throws when it is not expected to, fix it.
This is like saying put a `try/catch(ignore)` everywhere. Seriously.
- ben336 11y agoLogging errors to the console can be helpful to find them during debugging/development (as opposed to having them fail silently). The goal isn't to leave errors in, its to expose them when something changes to make them happen so that you can do the 2 things above.
- esailija 11y agoYou need to configure or change your promise implementation if uncaught errors fail silently. In any case, logging error gives you no information anyway. Just try running: `console.log(new Error("..."))`. So at the very least you should do `catch(function(e){console.log(e.stack);})`
- neumino 11y agoYou can just crash (and still see the stacktrace) and automatically restart. You shouldn't leave these `catch/ignore` in your code in prod, this is a pretty good way to get undefined behaviors and maybe corrupted data.
- Too 11y agoYeah. In chrome if you enable "break on exceptions" it will also break on unhandled promise rejections. This will take care of all your debugging needs.
- nolanl 11y agoYep, Chrome is pretty great about printing unhandled promise rejections to the console. However, I just tested Firefox and Safari, and neither of them will warn you in that case - not to mention older browsers like Android <4.4 and IE <=11, which don't even have native promises! So if you're ever trying to debug promises in a non-Chrome browser, you may find my "insane" advice pretty helpful. :)