jweinst1
2/18/2017 - 3:26 AM

sample custom error with javascript

sample custom error with javascript

//Test Error

function OError(message, type) {
  this.message = message;
  this.type = type;
}


function foo(){
  throw new OError("Wrong Function", "List Error");
}

try {
  console.log(foo());
} catch(err){
  console.log(err.type, err.message);
}

//List Error Wrong Function