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 stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #throw #error
ADD COMMENT
Topic
Name
6+3 =