javascript raise error code example
Example 1: js throw error
throw new Error('Whoops!')
Example 2: javascript how to raise the error
if (..condition..) {
throw 'Error message';
}
Example 3: javascript try
var someNumber = 1;
try {
someNumber.replace("-",""); //You can't replace a int
} catch(err) {
console.log(err);
}
Example 4: javascript throw new error
throw new Error("Error message here"); // Uncaught Error: Error message here