Answers for "throw new error"

39

js throw error

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

node js throw error

FactoryController.prototype.create = function (callback) {
    //The throw is working, and the exception is returned.
    throw new Error('An error occurred'); //outside callback 
    try {
        this.check(function (check_result) {
            callback(check_result);
        });
    } catch (ex) {
        throw new Error(ex.toString());
    }
}

FactoryController.prototype.create = function (callback) {
    try {
        this.check(function (check_result) {
            //The throw is not working on this case to return the exception to the caller(parent)
            throw new Error('An error occurred'); //inside callback 
        });
    } catch (ex) {
        throw new Error(ex.toString());
    }
}
Posted by: Guest on May-05-2020
1

throw new error(

try {
  throw new Error('yoooooooo!')
} catch (e) {
  console.error(e)
}
Posted by: Guest on October-21-2021
1

throw new error(

try{
throw new Error ('Whoops!)
}catch (e) {
 console.log(e.name + ':' + e.message
Posted by: Guest on September-21-2021

Browse Popular Code Answers by Language