I have an object with functions that cause errors,
myObj = {
ini:function(){
this.f();
},
f:function(){
throw new Error();
}
};
but I only want to catch exceptions when the object is created
try{
var o = new myObj();
}catch(err){
alert("error!");
}
it looks like I should have try / catch blocks everywhere = / to catch an error event in different areas of functions
try{
myObj = {
ini:function(){
try{
this.f();
}catch(err){
alert("f threw an err");
}
},
f:function(){
throw new Error();
}
};
}catch(err){
alert("error happend while crating Obj");
}
But I only want to capture from one place = / How to do it?
source
share