File tree Expand file tree Collapse file tree 3 files changed +17
-25
lines changed Expand file tree Collapse file tree 3 files changed +17
-25
lines changed Original file line number Diff line number Diff line change @@ -1158,30 +1158,14 @@ export class MongoServerSelectionError extends MongoSystemError {
1158
1158
}
1159
1159
}
1160
1160
1161
- /**
1162
- * The type of the result property of MongoWriteConcernError
1163
- * @public
1164
- */
1165
- export interface WriteConcernErrorResult {
1166
- writeConcernError : {
1167
- code : number ;
1168
- errmsg : string ;
1169
- codeName ?: string ;
1170
- errInfo ?: Document ;
1171
- } ;
1172
- ok : 0 | 1 ;
1173
- code ?: number ;
1174
- [ x : string | number ] : unknown ;
1175
- }
1176
-
1177
1161
/**
1178
1162
* An error thrown when the server reports a writeConcernError
1179
1163
* @public
1180
1164
* @category Error
1181
1165
*/
1182
1166
export class MongoWriteConcernError extends MongoServerError {
1183
1167
/** The result document */
1184
- result : WriteConcernErrorResult ;
1168
+ result : Document ;
1185
1169
1186
1170
/**
1187
1171
* **Do not use this constructor!**
@@ -1194,9 +1178,18 @@ export class MongoWriteConcernError extends MongoServerError {
1194
1178
*
1195
1179
* @public
1196
1180
**/
1197
- constructor ( result : WriteConcernErrorResult ) {
1198
- super ( result ) ;
1199
- this . errInfo = result . writeConcernError ?. errInfo ;
1181
+ constructor ( result : {
1182
+ writeConcernError : {
1183
+ code : number ;
1184
+ errmsg : string ;
1185
+ codeName ?: string ;
1186
+ errInfo ?: Document ;
1187
+ } ;
1188
+ errorLabels ?: string [ ] ;
1189
+ code ?: number ;
1190
+ } ) {
1191
+ super ( { ...result , ...result . writeConcernError } ) ;
1192
+ this . errInfo = result . writeConcernError . errInfo ;
1200
1193
this . result = result ;
1201
1194
this . code = result . code ? result . code : undefined ;
1202
1195
}
Original file line number Diff line number Diff line change @@ -30,8 +30,7 @@ import {
30
30
setDifference ,
31
31
type TopologyDescription ,
32
32
type TopologyOptions ,
33
- WaitQueueTimeoutError as MongoWaitQueueTimeoutError ,
34
- WriteConcernErrorResult
33
+ WaitQueueTimeoutError as MongoWaitQueueTimeoutError
35
34
} from '../mongodb' ;
36
35
import { ReplSetFixture } from '../tools/common' ;
37
36
import { cleanup } from '../tools/mongodb-mock/index' ;
@@ -745,7 +744,7 @@ describe('MongoErrors', () => {
745
744
describe ( 'MongoWriteConcernError constructor' , function ( ) {
746
745
context ( 'when no top-level code is provided and writeConcernError.code exists' , function ( ) {
747
746
it ( 'error.code remains undefined' , function ( ) {
748
- const res : WriteConcernErrorResult = {
747
+ const res = {
749
748
writeConcernError : {
750
749
code : 81 , // nested code
751
750
errmsg : 'fake msg'
@@ -758,7 +757,7 @@ describe('MongoErrors', () => {
758
757
context ( 'when top-level code is provided and writeConcernError.code exists' , function ( ) {
759
758
it ( 'error.code equals the top-level code' , function ( ) {
760
759
const topLevelCode = 10 ;
761
- const res : WriteConcernErrorResult = {
760
+ const res = {
762
761
writeConcernError : {
763
762
code : 81 , // nested code
764
763
errmsg : 'fake msg'
Original file line number Diff line number Diff line change @@ -737,7 +737,7 @@ describe('MongoClient', function () {
737
737
expect ( error ) . to . have . property ( 'code' , 'EBADNAME' ) ;
738
738
} ) ;
739
739
740
- it . only ( 'srvServiceName should not error if it is greater than 15 characters as long as the DNS query limit is not surpassed' , async ( ) => {
740
+ it ( 'srvServiceName should not error if it is greater than 15 characters as long as the DNS query limit is not surpassed' , async ( ) => {
741
741
const options = parseOptions ( 'mongodb+srv://localhost.a.com' , {
742
742
srvServiceName : 'a' . repeat ( 16 )
743
743
} ) ;
You can’t perform that action at this time.
0 commit comments