stack Property (Error) (JavaScript)
Gets or sets the error stack as a string that contains the stack trace frames.
Syntax
object
.stack
Remarks
The stack
property is set to undefined
when the error is constructed, and gets the trace information when the error is raised. If an error is raised multiple times, the stack
property is updated each time the error is raised.
Stack frames are displayed in the following format: at FunctionName (<Fully-qualified name/URL>:<line number>:<column number>)
If you create your own Error object and set the stack trace to a value, the value won't be overwritten when the error is thrown.
The stack
property does not show inline functions in its frames. It shows only the physical stack.
Example
The following example shows how to get the stack when you're catching an error.
try
{
var x = y.name;
}
catch(e)
{
document.write ("Error stack: ")
document.write (e.stack);
}
Example
The following example shows how to set and then get the stack.
try
{
var err = Error("my error");
err.stack = "my stack trace";
throw err;
}
catch(e)
{
document.write ("Error stack: ")
document.write (e.stack);
}
Requirements
Supported in the following document modes: Internet Explorer 10 standards and Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1). See Version Information.
Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards.
Applies To: Error Object
See Also
description Property (Error)
message Property (Error)
name Property (Error)
stackTraceLimit Property (Error)