Lodash _.isError() method

Beginner
⏱️ 6 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.isError(value) spots Error instances across common subclasses.
  • Why plain objects with message/name keys fail the check.
  • How lodash reasoning differs from bare instanceof Error in edge realms.
  • When DOM-style exceptions participate in the same utility.

Prerequisites

Basic familiarity with JavaScript exceptions (try/catch) and the Error type hierarchy.

  • You understand constructors (Error) versus instances (new Error()).
  • Try-it labs load lodash from the CDN.

Overview

Use _.isError inside lodash-heavy pipelines when APIs claim they reject with Errors but might leak strings, POJO payloads, or framework wrappers.

Tagged natives

Leverages internal object tags for reliable classification.

Reject impostors

Plain objects mimicking message/name rarely qualify.

Broader than manual checks

Centralizes quirks around DOMException-style hosts.

Syntax

javascript
_.isError(value)
  • value: any value to test.
  • Returns: true if value looks like an Error/DOMException-like host per lodash rules; otherwise false.
1

Error and TypeError instances

Built-in subclasses remain identifiable after construction.

javascript
import isError from "lodash/isError";

console.log(
  "genericErr: " + isError(new Error("oops")) + "\n" +       // true
  "typeErr: " + isError(new TypeError("bad"))                // true
);
Try it Yourself
2

Plain objects and strings masquerading as errors

Serializable shapes and stack-looking strings do not adopt Error tagging.

javascript
import isError from "lodash/isError";

console.log(
  "fakePlain: " + isError({ message: "fail", name: "Error" }) + "\n" + // false
  "errString: " + isError("Error: fail")                               // false
);
Try it Yourself
3

EvalError versus the Error constructor

Instances pass; the constructor function itself is not an error object.

javascript
import isError from "lodash/isError";

console.log(
  "evalErr: " + isError(new EvalError("bad eval")) + "\n" + // true
  "errorCtor: " + isError(Error)                            // false
);
Try it Yourself

📋 _.isError vs related checks

APIMatches
_.isError(x)Error-shaped tagged objects (plus lodash fallback rules).
x instanceof ErrorOften equivalent, but can fail across realms or exotic prototypes.
typeof x === "object" && x && "message" in xToo permissive—accepts plain POJOs.
_.isString(x)Useful when APIs mistakenly reject string stacks instead of Errors.

Pitfalls to avoid

Serialization

JSON loses prototypes

Parsed API payloads become plain objects—even when fields mimic Errors.

Frameworks

Wrapped failures

Some libraries attach cause chains or aggregate arrays—still Errors, but inspect metadata separately.

Naming

Error constructor misuse

Never confuse Error (function) with new Error() (instance).

❓ FAQ

No. Strings lack Error tagging—even when text resembles a stack line.
Usually no if lodash classifies it as a plain object, because lodash rejects plain-object impersonators unless tags indicate Error/DOMException.
Yes. Standard subclasses inherit Error internals so lodash sees compatible tags/shapes.
Where DOMException exists, lodash recognizes its tag similarly to Error instances.

Summary

  • Purpose: classify unknown rejection reasons as real Error hosts.
  • Reject: strings and plain-object impersonators lacking Error tagging.
  • Next: explore more on Lodash _.isFinite().
Did you know?

_.isError uses internal tags ([object Error], [object DOMException]) plus a guarded fallback for objects that expose string message and name fields yet cannot be classified as lodash plain objects—so copying keys onto {} is typically rejected.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful