W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2001

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

From: Jeff Yates <PBWiz@mail.pbwizard.com>
Date: Wed, 16 May 2001 02:35:27 -0400
Message-Id: <200105160235.AA211943642@mail.pbwizard.com>
To: <www-dom@w3.org>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:48 GMT