Michael D. Edwards
Software Design Engineer
Microsoft Corporation
March 11, 1999
The following table compares the error-handling techniques discussed in "Handling and Avoiding Web Page Errors Part 2: Run-time Errors".
Error Handling Technique | Cross-Browser | Can Resume Execution | Errors Handled | Can Pass Error to other Handler | Can Define Custom Errors |
window.onerror |
Navigator 3.x, 4.x, 5 Internet Explorer 4.x, 5 |
no, further execution is aborted until next user action or handled event | handles all run-time script errors not already handled via other techniques | from custom handler to default handler via DHTML event bubbling | DHTML event model is not customizable |
ECMAScript 2.0 JavaScript 1.4 JScript 5.0 |
Navigator 51 Internet Explorer 5 |
execution resumes in catch block and then optional finally block | handles run-time script errors only within try blocks | try...catch blocks can be nested, use throw to pass up the chain2 | throw argument can be any user-defined string, number or object variable |
VBScript | Internet Explorer 3.x, 4.x, 53 | execution resumes on line following line that caused error (user must check for error with if statement) | enabled by On Error Resume Next, active for all remaining statements in procedure or <SCRIPT> block, or until On Error Goto 0 | user controls whether to invoke error handler where errors occur, or at higher level (in the caller) | Err.Raise initializes Err object properties to user-defined values |
1JavaScript 1.4 lacks support for handling run-time errors from the script engine
2window.onerror handler is invoked if throw from highest-order try...catch block
3VBScript is not supported on the Mac OS