Skip to content

Commit

Permalink
streamline code
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB committed Jul 26, 2024
1 parent 26e5640 commit 10a6629
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1196,10 +1196,9 @@ export class MongoWriteConcernError extends MongoServerError {
* @public
**/
constructor(result: WriteConcernErrorResult) {
super({ ...result, ...result.writeConcernError });
super({ ...result.writeConcernError, ...result });
this.errInfo = result.writeConcernError.errInfo;
this.result = result;
this.code = result.code ?? result.writeConcernError.code ?? undefined;
}

override get name(): string {
Expand Down Expand Up @@ -1247,7 +1246,7 @@ export function needsRetryableWriteLabel(error: Error, maxWireVersion: number):
}

if (error instanceof MongoWriteConcernError) {
return RETRYABLE_WRITE_ERROR_CODES.has(error.result?.code ?? error.code ?? 0);
return RETRYABLE_WRITE_ERROR_CODES.has(error.result.writeConcernError.code ?? error?.code ?? 0);
}

if (error instanceof MongoError && typeof error.code === 'number') {
Expand Down

0 comments on commit 10a6629

Please sign in to comment.