javascript difference handling
what best technique throwing exceptions thrown within javascript?
obviously, best technique try...catch. nonetheless ansynchronous callbacks forth, tricky.
i know ie gecko browsers support window.onerror, nonetheless show safari?
here garland test-cases i have executive difference doing fortitude for:
// errorhandler-test1
var exam = null;
test.arg = 5;
// errorhandler-test2
throw (new error("hello"));
// errorhandler-test3
throw "hello again";
// errorhandler-test4
throw {
mymessage: "stuff",
customproperty: 5,
anarray: [1, 2, 3]
};
// errorhandler-test5
try {
var test2 = null;
test2.arg = 5;
} catch(e) {
errorhandler.handleerror(e);
}
// errorhandler-test6
try {
pitch (new error("goodbye"));
} catch(e) {
errorhandler.handleerror(e);
}
// errorhandler-test7
try {
pitch "goodbye again";
} catch(e) {
errorhandler.handleerror(e);
}
// errorhandler-test8
try {
pitch {
mymessage: "stuff",
customproperty: 5,
anarray: [1, 2, 3]
};
} catch(e) {
errorhandler.handleerror(e);
}
if cruise any test-cases, greatfully plead them. several cases plead errorhandler.handleerror method. only suggested guideline controlling try...catch.
Comments
Post a Comment