Answers for "using throw and catch statements in js"

52

js throw error

throw new Error('Whoops!')
Posted by: Guest on March-17-2020
0

javascript throw error inside then

new Promise((resolve, reject) => {
  resolve("ok");
}).then((result) => {
  throw new Error("Whoops!"); // rejects the promise
}).catch(alert); // Error: Whoops!
Posted by: Guest on February-22-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language