0
// Create an object type UserException
function UserException (message){
this.message=message;
this.name="UserException";
}
// Make the exception convert to a pretty string when used as
// a string (e.g. by the error console)
UserException.prototype.toString = function(){
return this.name + ': "' + this.message + '"';
}
// Create an instance of the object type and throw it
throw new UserException("Value too high");
Как это будет использоваться?Может кто-нибудь объяснить этот код JavaScript мне?
Вы знакомы с метаморфозами? Я пытаюсь определить, на каком уровне это объяснить. –
http://stackoverflow.com/questions/464359/custom-exceptions-in-javascript – jball
http://en.wikipedia.org/wiki/Exception_handling –