Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

name property

Returns a DOMString value an error that occurred during a Document Object Model (DOM) operation.

This property is read-only.

Internet Explorer 10

 

Syntax

JavaScript
sErrorName = object.name

 

Property values

Type: DOMString

A DOM Error Code.

Remarks

The name property indicates the type of error that occurred. Because DOMException objects and DOMError objects both return DOM error codes, it is possible to create general routines to handle errors consistently.

Examples

The following example shows one way to create a shared error handler using JavaScript:


var fileReader = new FileReader();

fileReader.onerror = function() {
   handleError(this.error); 
};

try {
   fileReader.readAsArrayBuffer(blob);
} 
   catch(exception) {
      handleError(exception);
   }

// handleError can be used for either 
// DOMError or DOMException errors

function handleError(error) {
   if (error.name == "NotFoundError")
      handleNotFoundError();
   if (error.name == "InvalidStateError")
      handleInvalidStateError();
}

See also

DOMError
DOMException

 

 

Show:
© 2015 Microsoft