| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Error#error_types | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..
* Some parts of this feature may have varying levels of support.
Error . Error . .
Error.
Error , structuredClone() postMessage().
EvalError , , eval().
RangeError, , .
ReferenceError, , .
SyntaxError , , eval().
TypeError, , .
URIError , , encodeURI() decodeURI() .
AggregateError , , . , , Promise.any().
InternalError , , JavaScript. , (too much recursion).
Error() Error.
Error.captureStackTrace() V8, stack Error.
Error.stackTraceLimit V8, , .
Error.prepareStackTrace() V8, ( ) JavaScript- V8 , .
Error.prototype Error.
Error.prototype.constructor-, . Error Error.
Error.prototype.name . Error.prototype.name "Error". (, TypeError SyntaxError) name.
Error.prototype.stack , .
Error.
cause . Error cause .
Mozilla, , .
fileName Mozilla, , .
lineNumber Mozilla, , .
message . Error , .
, Error throw. try...catch:
try {
throw new Error("!");
} catch (e) {
console.error(`${e.name}: ${e.message}`);
}
try {
foo.bar();
} catch (e) {
if (e instanceof EvalError) {
console.error(`${e.name}: ${e.message}`);
} else if (e instanceof RangeError) {
console.error(`${e.name}: ${e.message}`);
}
//
else {
// ,
throw e;
}
}
, Error, throw new MyError() instanceof MyError . .
Error JavaScript ? StackOverflow.
:
ES6 , new.target Reflect.construct(). Object.setPrototypeOf(this, CustomError.prototype) , CustomError. TypeScript FAQ .
:
CustomError ES2015.
class CustomError extends Error {
constructor(foo = "bar", ...params) {
// ( )
super(...params);
// ( V8)
if (Error.captureStackTrace) {
Error.captureStackTrace(this, CustomError);
}
this.name = "CustomError";
//
this.foo = foo;
this.date = new Date();
}
}
try {
throw new CustomError("baz", "bazMessage");
} catch (e) {
console.error(e.name); // CustomError
console.error(e.foo); // baz
console.error(e.message); // bazMessage
console.error(e.stack); // stacktrace
}
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-error-objects |
This page was last modified on 29 . 2026 . by MDN contributors.
ErrorObject/FunctionObject.prototype.__defineGetter__()Object.prototype.__defineSetter__()Object.prototype.__lookupGetter__()Object.prototype.__lookupSetter__()Object.prototype.hasOwnProperty()Object.prototype.isPrototypeOf()Object.prototype.propertyIsEnumerable()Object.prototype.toLocaleString()Object.prototype.toString()Object.prototype.valueOf()AggregateErrorEvalErrorInternalErrorRangeErrorReferenceErrorSyntaxErrorTypeErrorURIErrorYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |