node.js - Catching Errors in JavaScript Promises with a First Level try ... catch -
Therefore, I want my first level cache that handles the error
Promise = Requirement ('.framework / libraries / requires) bluebird.js'); Function promise () {var promise = new promise (work (solution, reject) {throw ('oh no!');}); Promise.catch (function (error) {throw (error);}); } Try {Promise (); } // I want to catch this error in the inclination (error) {console.log ('caught!', Error); }
With the new you can get it Please note that at the time of writing It is not supported by all browsers, you probably have to read your code (or something similar). Because of the keyword "getonome", getSomeValue () // will return a promise from the call async function getSomeValue () {if (Some IsNotOk) {new error ('oh oh'); } And {return "ya!"; }} Async function () {try "//" will wait for the promise to resolve or reject if it rejects, then an error will be thrown, which you // regularly hold / hold block SomeValue = waiting for some value (); doSomethingWith (someValue);} hold (error) {console.error (error);}}
Comments
Post a Comment