Overview

An error representing a 2XX error returned from the Data API (such as duplicate ID errors, certain validation errors, etc.)

Hierarchy (view full)

Constructors

Properties

command: Record<string, any>

The original command that was sent to the API, as a plain object. This is the raw command, not necessarily in the exact format the client may use, in some rare cases.

Example

{
insertOne: {
document: { _id: 'doc10', name: 'Document 10' },
},
}
message: string

A human-readable message describing the first error.

This is always equal to errorDescriptors[0]?.message if it exists, otherwise it's given a generic default message.

name: string
rawResponse: RawDataAPIResponse & {
    errors: ReadonlyNonEmpty<DataAPIErrorDescriptor>;
}

The raw response from the API

Type declaration

Example

{
status: {
insertedIds: [ 'id1', 'id2', 'id3']
},
errors: [
{
family: 'REQUEST',
scope: 'DOCUMENT',
errorCode: 'DOCUMENT_ALREADY_EXISTS',
id: 'e4be94b6-e8b5-4652-961b-5c9fe12d2f1a',
title: 'Document already exists with the given _id',
message: 'Document already exists with the given _id',
},
]
}
stack?: string
prepareStackTrace?: ((err, stackTraces) => any)

Optional override for formatting stack traces

Type declaration

    • (err, stackTraces): any
    • Parameters

      • err: Error
      • stackTraces: CallSite[]

      Returns any

stackTraceLimit: number

Accessors

  • get warnings(): readonly DataAPIWarningDescriptor[]
  • A list of error descriptors representing the individual errors returned by the API.

    This will likely be a singleton list in many cases, such as for insertOne or deleteOne commands, but may be longer for bulk operations like insertMany which may have multiple insertion errors.

    Returns readonly DataAPIWarningDescriptor[]

Methods

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • Optional constructorOpt: Function

    Returns void