RE: DOM 3 Core: Overlap with JAXP, Document order of attributes, getChildElementsByTagName, Exceptions

If the DOM you are using follows the W3C Recomendation then you use the instanceof operator in JavaScript to find out what exception object was thrown.  After you get that then you use the value of the code property to get the exact error thrown. 

If the DOM you are using follows the W3C Recomendation you can use the following:

try{
    //error prone code
}catch(err){
  if( err instanceof DOMException ){
    switch( err.code ){
    case DOMException.INDEX_SIZE_ERR:  //error handling code here
    case DOMException.DOMSTRING_SIZE_ERR:  //error handling code here
    case DOMException.HIERARCHY_REQUEST_ERR:  //error handling code here
    .
    .
    .
    case DOMException.INVALID_ACCESS_ERR:  //error handling code here
    } 
  } else if( err instanceof EventException ){
    if( err.code == EventException.UNSPECIFIED_EVENT_TYPE_ERR )
      //error handling code here
  } else if( ... ){
    .
    .
    .
  }
}

--
Jeff Yates
e-mail:    PBWiz@PBWizard.com
Homepage:  http://www.PBWizard.com

--

Received on Wednesday, 16 May 2001 02:35:37 UTC