//create error object
var error = new Object();
error.reason="some reason!";
//business function
function exception(){
try{
throw error;
}catch(err){
err.reason;
}
}
Now we set add the reason or whatever properties we want to the error object and retrieve it. By making the error more reasonable.