Error.isError(value) checks whether a value is a real Error object. It returns true for Error, for built-in types such as TypeError and RangeError, and for classes that extend Error. For every other value it returns false.
It is more reliable than value instanceof Error. That check can say true for an object that only inherits from Error.prototype, and false for a real error that was created in another iframe or window. Error.isError() looks at how the object was made, so it answers correctly in both cases. It is a newer method, so see the browser support section.
Remember
Error.isError(new Error("x")) → true
Error.isError(new TypeError("x")) → true
Error.isError({ message: "x" }) → false
Error.isError("x") → false
Error.isError() → false
It never throws and never changes the value.
Syntax
Call isError() on the Error constructor itself, not on the value you want to test. Pass that value as the only argument.
JavaScript
Error.isError(value);
Call
What it does
Error.isError(err)
Returns true for a real error object and false for anything else.
if (Error.isError(problem)) { ... }
Use it in a catch block to treat errors and other thrown values differently.
typeof Error.isError === "function"
Check that the method exists first when your code may run in an older browser or Node.js version.
Built into JavaScript as a newer method; no import required, but check that it exists in older environments. Siblings: Error.captureStackTrace() and toString().
A list of samples. Each item holds a label for the output and the value to test, so the loop prints what was tested next to the answer.
Real errors say true.new Error() and new TypeError() both create genuine Error objects.
Look-alikes say false. An object with name and message, a string that looks like an error message, and null are not Error objects, however similar they look.
Example 2 — Compare isError() with instanceof
An object that only inherits from Error.prototype fools instanceof but not Error.isError().
real instanceof Error: true
real isError: true
fake instanceof Error: true
fake isError: false
How It Works
Two objects.real is created with new DiskError(), so it is a genuine error. fake is a plain object whose prototype is Error.prototype.
instanceof follows the prototype. It only asks whether Error.prototype is somewhere in the chain, so it says true for both objects.
isError() checks how it was made. Only real was built by the Error machinery, so only real gets true. The same idea makes it work for errors from other iframes.
Example 3 — Handle Anything a catch Block Receives
JavaScript lets you throw any value. Check what you caught before you read message, and keep a fallback for older engines.
JavaScript
function isError(value) {
return typeof Error.isError === "function"
? Error.isError(value)
: value instanceof Error;
}
const jobs = [
() => { throw new Error("Disk full"); },
() => { throw "timeout"; },
() => { throw { code: 500 }; },
() => { throw new RangeError("Quota exceeded"); }
];
for (const job of jobs) {
try {
job();
} catch (problem) {
if (isError(problem)) {
console.log("Error: " + problem.message);
} else {
console.log("Not an Error: " + JSON.stringify(problem));
}
}
}
Error: Disk full
Not an Error: "timeout"
Not an Error: {"code":500}
Error: Quota exceeded
How It Works
A safe wrapper.isError() uses Error.isError() when it exists and falls back to instanceof Error when it does not, so the code runs in older environments too.
Four different throws. Two jobs throw real errors, one throws a string and one throws a plain object. All of them land in the same catch block.
Handle each kind. Real errors have a message to print. Other values have none, so JSON.stringify() shows what they actually are.
Compatibility
Browser & Runtime Support
Error.isError() is a newer JavaScript method. Current versions of the major browsers and Node.js 24 have it; older ones do not.
✓ Newer API · check support
Error.isError()
Supported in Chrome 134+, Edge 134+, Firefox 138+ and Node.js 24+. Other browsers and runtimes follow in recent versions, so check the version. Internet Explorer never got it.
NewerCheck before use
Google Chrome134+ · Desktop & Mobile
Full support
Microsoft Edge134+ · Chromium
Full support
Mozilla Firefox138+ · Desktop & Mobile
Full support
Apple SafariCheck the version · macOS & iOS
Check support
OperaRecent versions · Chromium based
Check support
Samsung InternetRecent versions · Android
Check support
Android WebViewRecent versions · Chromium based
Check support
Node.js24+ · Server runtime
Supported
DenoRecent versions · JavaScript runtime
Supported
BunCheck the version · JavaScript runtime
Check support
Internet ExplorerNo native support
Not supported
Error.isError()Growing
Bottom line: Fine for current browsers and Node.js 24, but keep the instanceof Error fallback from Example 3 when you must support older ones.
Frequently Asked Questions
It returns true when the value is a real Error object (an Error, a built-in type such as TypeError, or an instance of a class that extends Error) and false for everything else, including strings, plain objects, null and undefined.
instanceof only checks the prototype chain, so an object created with Object.create(Error.prototype) passes, and a real error from another iframe or window fails. Error.isError() checks how the object was created, so it gets both cases right.
Yes. A class that extends Error (or TypeError and so on) creates real error objects, so Error.isError() returns true for its instances. A class that does not extend Error returns false, even if it has name and message properties.
Fall back to instanceof Error: typeof Error.isError === "function" ? Error.isError(value) : value instanceof Error. The fallback is slightly less strict, but it works everywhere and is usually good enough for catch blocks.
JavaScript lets you throw any value, so code can write throw "timeout" or throw { code: 500 }. Libraries and callbacks sometimes do this too. Check the value with Error.isError() before you read err.message, because a string or a number has no message.