Lodash _.isError() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Lang

Definition

Checks if value is an Error object (including subclasses like TypeError). It does not treat the Error constructor itself as an instance. Since Lodash 0.1.0.

Pass the value you want to inspect or convert. Read the return type carefully before you use the result.

Syntax

Call _.isError. Start with this line.

Lodash
_.isError(value)
CallWhat it does
_.isError(value)Primary signature.

Prefer import isError from "lodash/isError" when you want a smaller bundle.

Library declarations
Lodash
_.isError(value)

Parameters

ParameterDescription
valueRequired. The value to check

Return Value

Return ValueDescription
*true if Error object, else false

Lodash Examples

Example 1 — Official: Instance vs Constructor

Only Error instances pass — not the Error function.

Lodash
_.isError(new Error);
// → true

_.isError(Error);
// → false
Try It Yourself

How It Works

  1. new Error creates an instance with an Error tag.
  2. isError sees that tag → true.
  3. Error alone is a function → false.
  4. Lesson. Always check thrown/caught values, not the class itself.

Example 2 — Error Subclasses

TypeError, RangeError, and friends count as errors.

Lodash
_.isError(new TypeError("bad type"));
// → true

_.isError(new RangeError("out of range"));
// → true

_.isError(new SyntaxError("oops"));
// → true
Try It Yourself

How It Works

  1. Subclasses inherit Error internals.
  2. isError uses the same Error/DOMException classification.
  3. All three return true.
  4. Tip. Narrow further with err instanceof TypeError when needed.

Example 3 — Plain Object Impostor

Copying name and message onto {} does not fool Lodash.

Lodash
var fake = { name: "Error", message: "nope" };

_.isError(fake);
// → false

_.isPlainObject(fake);
// → true
Try It Yourself

How It Works

  1. fake is a normal object literal.
  2. Tag is [object Object], not Error.
  3. isError → false; isPlainObject → true.
  4. Lesson. Shape alone is not an Error.

Example 4 — Strings, Null, and Undefined

Thrown strings and empty values are not Error objects.

Lodash
_.isError("something went wrong");
// → false

_.isError(null);
// → false

_.isError(undefined);
// → false
Try It Yourself

How It Works

  1. String message text is still a string.
  2. null / undefined have no Error tag.
  3. All three return false.
  4. Prefer throw new Error(…) over throw "…".

Example 5 — Safe catch Guard

Branch on whether the caught value is a real Error.

Lodash
function describe(err) {
  if (_.isError(err)) {
    return err.name + ": " + err.message;
  }
  return "non-error: " + String(err);
}

describe(new TypeError("x is not a function"));
// → "TypeError: x is not a function"

describe("boom");
// → "non-error: boom"
Try It Yourself

How It Works

  1. isError gates access to name / message.
  2. TypeError instance → formatted Error string.
  3. Plain string → safe fallback path.
  4. Use case. Logging and UI messages for mixed throw styles.

Browser & Runtime Support

_.isError is a Lodash Lang helper (since 0.1.0). It runs anywhere Lodash 4.x runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 0.1.0+

_.isError()

Available in [email protected] full builds and the lodash/isError modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.isError Lodash 0.1.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import isError from "lodash/isError". DOMException recognition applies in browser hosts that provide it.

Frequently Asked Questions

_.isError(value) returns true if value is classified as an Error object (including subclasses), otherwise false.
No. Error is the constructor function. Pass an instance: new Error("…").
Yes. Standard Error subclasses inherit Error tagging, so _.isError returns true.
No. Lodash looks for Error / DOMException tags — copying keys onto {} is not enough.
throw "oops" yields a string. _.isError returns false. Prefer throw new Error("oops").
Use import isError from "lodash/isError" or require("lodash/isError") for tree-shaking. Full build: import _ from "lodash" then _.isError.

Next: _.isFinite()

Check whether a value is a finite number.

_.isFinite() tutorial →

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.

11 people found this page helpful