function MyError(message) {
this.message = message;
}
MyError.prototype = new Error;
This allows for usage like..
try {
something();
} catch(e) {
if(e instanceof MyError)
doSomethingElse();
else if(e instanceof Error)
andNowForSomethingCompletelyDifferent();
}