EventException object (Object/DOM)

An object that describes the kind of event-based exception that has occurred.


DOM level - 2
JavaScript - 1.5
Netscape - 6.0
JavaScript syntax:NmyEventException = new EventException()
Object properties:code

During the processing of an event with its handler, some unexpected circumstance may cause an exception to occur. This is not quite the same as a try ... catch exception as defined in ECMAScript.

DOM level 2 describes an EventException object, but it's not obvious how this would be associated with any JavaScript function that could be set up to catch it. The DOM level 2 event specification is founded on the principle that the implementation should be at least ECMAScript (third edition) compliant. This should ensure it has sophisticated enough error handling support to cope with an exception being thrown. Neither specification describes in detail exactly how this should happen and so it is likely that, whilst we may have browsers that support a standard and consistent object model, we still have portability problems because they implement the surrounding infrastructure differently.

Assuming that a function handler were called, it would be passed a reference to an EventException object from which it could obtain a code value that describes the cause of the exception. Perhaps, the onError handler may be used to trap this but an implementation might choose to provide an onException handler.

At DOM level 2, only the UNSPECIFIED_EVENT_TYPE_ERR is defined as a static constant. This has the value 0. Other event types may be defined in later versions of the DOM specification.

See also:EventTarget.dispatchEvent()

code1.5 1.5 n/a6.0 6.0 n/a n/a n/a n/a2 2 n/a n/a-