Automattic/mongoose · error · Error

`error` must be `instanceof Error`.

Error message

`error` must be `instanceof Error`.

What it means

Error "`error` must be `instanceof Error`." thrown in Automattic/mongoose.

Source

Thrown at lib/utils.js:1031

    }
    if (source[name] != null) {
      return source[name];
    }
  }

  return null;
};

/*!
 * ignore
 */

exports.noop = function() {};

exports.errorToPOJO = function errorToPOJO(error) {
  const isError = error instanceof Error;
  if (!isError) {
    throw new Error('`error` must be `instanceof Error`.');
  }

  const ret = {};
  for (const properyName of Object.getOwnPropertyNames(error)) {
    ret[properyName] = error[properyName];
  }
  return ret;
};

/*!
 * ignore
 */

exports.warn = function warn(message) {
  return process.emitWarning(message, { code: 'MONGOOSE' });
};

View on GitHub (pinned to 49cdab0136)

When it happens

Trigger: Thrown at lib/utils.js:1031 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Automattic/mongoose@49cdab0136 (2026-08-21). Data as JSON: /api/errors/8ea7d6d33f2441c7. Report an issue: GitHub.