Catching the 'Object Expected' Error : Error Exceptions « Development « JavaScript DHTML

Catching the 'Object Expected' Error

function dosomething() { 

function goodFunc(){ 
   try { 
   catch (e) { 
      if (e.description == "Object expected") { 
         alert("Cannot find a function named doSomething!"); 
      else { 
         alert ("Other error" + e.description); 
<INPUT type=button value="Click" onClick="goodFunc();">


Related examples in the same category

1.Throwing an Error
2.Catching an Error
3.Controlling Script Errors
4.An Exception Handling Example
5.Nested Exception Handling (This script only works with Internet Explorer 5, Navigator 6, or later browsers)
6.Using the onError Event Handler
7. Throwing String Exceptions
8.Throwing an Error Object Exception
9.A Custom Object Exception