MCPcopy
hub / github.com/mongodb/node-mongodb-native / throwIfWriteConcernError

Function throwIfWriteConcernError

src/write_concern.ts:170–183  ·  view source on GitHub ↗
(response: unknown)

Source from the content-addressed store, hash-verified

168
169/** Called with either a plain object or MongoDBResponse */
170export function throwIfWriteConcernError(response: unknown): void {
171 if (typeof response === 'object' && response != null) {
172 const writeConcernError: object | null =
173 MongoDBResponse.is(response) && response.has('writeConcernError')
174 ? response.toObject()
175 : !MongoDBResponse.is(response) && 'writeConcernError' in response
176 ? response
177 : null;
178
179 if (writeConcernError != null) {
180 throw new MongoWriteConcernError(writeConcernError as any);
181 }
182 }
183}

Callers 1

commandMethod · 0.90

Calls 3

isMethod · 0.45
hasMethod · 0.45
toObjectMethod · 0.45

Tested by

no test coverage detected