JavaScript Error Reference


Error Object

The Error object provides error information when an error occurs.

Example

In this example we have written "alert" as "adddlert" to deliberately produce an error.

Return the error name and a description of the error:

try {
  adddlert("Welcome");
}
catch(err) {
  document.getElementById("demo").innerHTML =
  err.name + "<br>" + err.message;
}
Try it Yourself »

For a tutorial about JavaScript Errors, read our JavaScript Error Tutorial.


Error Object Properties

Property Description
name Sets or returns an error name
message Sets or returns an error message (a string)

Error Names

Error NameDescriptionTry it
EvalErrorDeprecated - use SyntaxError instead 
RangeErrorA number "out of range" has occurredTry it »
ReferenceErrorAn illegal reference has occurredTry it »
SyntaxErrorA syntax error has occurredTry it »
TypeErrorA type error has occurredTry it »
URIErrorAn error in encodeURI() has occurredTry it »

Non-Standard Properties and Methods

Do not use these properties and methods in public web sites. They will not work in all browsers.

PropertyDescription
argumentsDeprecated
callerDeprecated
columnNumberFirefox only
descriptionMicrosoft only
displayNameFirefox only
fileNameFirefox only
lineNumberFirefox only
numberMicrosoft only
stackFirefox only
MethodsDescription
evalError()Deprecated
internalError()Firefox only
toSource()Non Standard

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.