Interface DataAPIDetailedErrorDescriptor

An object representing a complete error response from the Data API, including the original command that was sent, and the raw API response from the server.

This is not used for "hard" (4XX, 5XX) errors, which are rarer and would be thrown directly by the underlying code.

Field

errorDescriptors - A list of error descriptors representing the individual errors returned by the API

Field

command - The raw command send to the API

Field

rawResponse - The raw response from the API

interface DataAPIDetailedErrorDescriptor {
    command: Record<string, any>;
    errorDescriptors: DataAPIErrorDescriptor[];
    rawResponse: RawDataAPIResponse;
}

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, even with bulkWrite.

Example

{
  insertOne: {
  document: { _id: 'docml10', name: 'Document 10' },
  }
}
errorDescriptors: DataAPIErrorDescriptor[]

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.

rawResponse: RawDataAPIResponse

The raw response from the API

Example

{
  status: {
  insertedIds: [ 'id1', 'id2', 'id3']
  },
  data: undefined,
  errors: [
  {
  message: "Failed to insert document with _id 'id3': Document already exists with the given _id",
  errorCode: 'DOCUMENT_ALREADY_EXISTS'
  }
  ]
}