Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript throw error inside then

new Promise((resolve, reject) => {
  resolve("ok");
}).then((result) => {
  throw new Error("Whoops!"); // rejects the promise
}).catch(alert); // Error: Whoops!
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #javascript #throw #error
ADD COMMENT
Topic
Name
8+4 =