-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
error.ts
1316 lines (1187 loc) · 34.7 KB
/
error.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import type { Document } from './bson';
import type { TopologyVersion } from './sdam/server_description';
import type { TopologyDescription } from './sdam/topology_description';
/** @public */
export type AnyError = MongoError | Error;
/** @internal */
const kErrorLabels = Symbol('errorLabels');
/**
* @internal
* The legacy error message from the server that indicates the node is not a writable primary
* https://github.com/mongodb/specifications/blob/b07c26dc40d04ac20349f989db531c9845fdd755/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#not-writable-primary-and-node-is-recovering
*/
export const LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE = new RegExp('not master', 'i');
/**
* @internal
* The legacy error message from the server that indicates the node is not a primary or secondary
* https://github.com/mongodb/specifications/blob/b07c26dc40d04ac20349f989db531c9845fdd755/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#not-writable-primary-and-node-is-recovering
*/
export const LEGACY_NOT_PRIMARY_OR_SECONDARY_ERROR_MESSAGE = new RegExp(
'not master or secondary',
'i'
);
/**
* @internal
* The error message from the server that indicates the node is recovering
* https://github.com/mongodb/specifications/blob/b07c26dc40d04ac20349f989db531c9845fdd755/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#not-writable-primary-and-node-is-recovering
*/
export const NODE_IS_RECOVERING_ERROR_MESSAGE = new RegExp('node is recovering', 'i');
/** @internal MongoDB Error Codes */
export const MONGODB_ERROR_CODES = Object.freeze({
HostUnreachable: 6,
HostNotFound: 7,
NetworkTimeout: 89,
ShutdownInProgress: 91,
PrimarySteppedDown: 189,
ExceededTimeLimit: 262,
SocketException: 9001,
NotWritablePrimary: 10107,
InterruptedAtShutdown: 11600,
InterruptedDueToReplStateChange: 11602,
NotPrimaryNoSecondaryOk: 13435,
NotPrimaryOrSecondary: 13436,
StaleShardVersion: 63,
StaleEpoch: 150,
StaleConfig: 13388,
RetryChangeStream: 234,
FailedToSatisfyReadPreference: 133,
CursorNotFound: 43,
LegacyNotPrimary: 10058,
WriteConcernFailed: 64,
NamespaceNotFound: 26,
IllegalOperation: 20,
MaxTimeMSExpired: 50,
UnknownReplWriteConcern: 79,
UnsatisfiableWriteConcern: 100,
Reauthenticate: 391
} as const);
// From spec@https://github.com/mongodb/specifications/blob/f93d78191f3db2898a59013a7ed5650352ef6da8/source/change-streams/change-streams.rst#resumable-error
export const GET_MORE_RESUMABLE_CODES = new Set<number>([
MONGODB_ERROR_CODES.HostUnreachable,
MONGODB_ERROR_CODES.HostNotFound,
MONGODB_ERROR_CODES.NetworkTimeout,
MONGODB_ERROR_CODES.ShutdownInProgress,
MONGODB_ERROR_CODES.PrimarySteppedDown,
MONGODB_ERROR_CODES.ExceededTimeLimit,
MONGODB_ERROR_CODES.SocketException,
MONGODB_ERROR_CODES.NotWritablePrimary,
MONGODB_ERROR_CODES.InterruptedAtShutdown,
MONGODB_ERROR_CODES.InterruptedDueToReplStateChange,
MONGODB_ERROR_CODES.NotPrimaryNoSecondaryOk,
MONGODB_ERROR_CODES.NotPrimaryOrSecondary,
MONGODB_ERROR_CODES.StaleShardVersion,
MONGODB_ERROR_CODES.StaleEpoch,
MONGODB_ERROR_CODES.StaleConfig,
MONGODB_ERROR_CODES.RetryChangeStream,
MONGODB_ERROR_CODES.FailedToSatisfyReadPreference,
MONGODB_ERROR_CODES.CursorNotFound
]);
/** @public */
export const MongoErrorLabel = Object.freeze({
RetryableWriteError: 'RetryableWriteError',
TransientTransactionError: 'TransientTransactionError',
UnknownTransactionCommitResult: 'UnknownTransactionCommitResult',
ResumableChangeStreamError: 'ResumableChangeStreamError',
HandshakeError: 'HandshakeError',
ResetPool: 'ResetPool',
InterruptInUseConnections: 'InterruptInUseConnections',
NoWritesPerformed: 'NoWritesPerformed'
} as const);
/** @public */
export type MongoErrorLabel = (typeof MongoErrorLabel)[keyof typeof MongoErrorLabel];
/** @public */
export interface ErrorDescription extends Document {
message?: string;
errmsg?: string;
$err?: string;
errorLabels?: string[];
errInfo?: Document;
}
function isAggregateError(e: Error): e is Error & { errors: Error[] } {
return 'errors' in e && Array.isArray(e.errors);
}
/**
* @public
* @category Error
*
* @privateRemarks
* mongodb-client-encryption has a dependency on this error, it uses the constructor with a string argument
*/
export class MongoError extends Error {
/** @internal */
[kErrorLabels]: Set<string>;
/**
* This is a number in MongoServerError and a string in MongoDriverError
* @privateRemarks
* Define the type override on the subclasses when we can use the override keyword
*/
code?: number | string;
topologyVersion?: TopologyVersion;
connectionGeneration?: number;
override cause?: Error;
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string, options?: { cause?: Error }) {
super(message, options);
this[kErrorLabels] = new Set();
}
/** @internal */
static buildErrorMessage(e: Error | string): string {
if (typeof e === 'string') {
return e;
}
if (isAggregateError(e) && e.message.length === 0) {
return e.errors.length === 0
? 'AggregateError has an empty errors array. Please check the `cause` property for more information.'
: e.errors.map(({ message }) => message).join(', ');
}
return e.message;
}
override get name(): string {
return 'MongoError';
}
/** Legacy name for server error responses */
get errmsg(): string {
return this.message;
}
/**
* Checks the error to see if it has an error label
*
* @param label - The error label to check for
* @returns returns true if the error has the provided error label
*/
hasErrorLabel(label: string): boolean {
return this[kErrorLabels].has(label);
}
addErrorLabel(label: string): void {
this[kErrorLabels].add(label);
}
get errorLabels(): string[] {
return Array.from(this[kErrorLabels]);
}
}
/**
* An error coming from the mongo server
*
* @public
* @category Error
*/
export class MongoServerError extends MongoError {
codeName?: string;
writeConcernError?: Document;
errInfo?: Document;
ok?: number;
[key: string]: any;
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: ErrorDescription) {
super(message.message || message.errmsg || message.$err || 'n/a');
if (message.errorLabels) {
this[kErrorLabels] = new Set(message.errorLabels);
}
for (const name in message) {
if (name !== 'errorLabels' && name !== 'errmsg' && name !== 'message')
this[name] = message[name];
}
}
override get name(): string {
return 'MongoServerError';
}
}
/**
* An error generated by the driver
*
* @public
* @category Error
*/
export class MongoDriverError extends MongoError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string, options?: { cause?: Error }) {
super(message, options);
}
override get name(): string {
return 'MongoDriverError';
}
}
/**
* An error generated when the driver API is used incorrectly
*
* @privateRemarks
* Should **never** be directly instantiated
*
* @public
* @category Error
*/
export class MongoAPIError extends MongoDriverError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string, options?: { cause?: Error }) {
super(message, options);
}
override get name(): string {
return 'MongoAPIError';
}
}
/**
* An error generated when the driver encounters unexpected input
* or reaches an unexpected/invalid internal state
*
* @privateRemarks
* Should **never** be directly instantiated.
*
* @public
* @category Error
*/
export class MongoRuntimeError extends MongoDriverError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string, options?: { cause?: Error }) {
super(message, options);
}
override get name(): string {
return 'MongoRuntimeError';
}
}
/**
* An error generated when a batch command is re-executed after one of the commands in the batch
* has failed
*
* @public
* @category Error
*/
export class MongoBatchReExecutionError extends MongoAPIError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message = 'This batch has already been executed, create new batch to execute') {
super(message);
}
override get name(): string {
return 'MongoBatchReExecutionError';
}
}
/**
* An error generated when the driver fails to decompress
* data received from the server.
*
* @public
* @category Error
*/
export class MongoDecompressionError extends MongoRuntimeError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string) {
super(message);
}
override get name(): string {
return 'MongoDecompressionError';
}
}
/**
* An error thrown when the user attempts to operate on a database or collection through a MongoClient
* that has not yet successfully called the "connect" method
*
* @public
* @category Error
*/
export class MongoNotConnectedError extends MongoAPIError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string) {
super(message);
}
override get name(): string {
return 'MongoNotConnectedError';
}
}
/**
* An error generated when the user makes a mistake in the usage of transactions.
* (e.g. attempting to commit a transaction with a readPreference other than primary)
*
* @public
* @category Error
*/
export class MongoTransactionError extends MongoAPIError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string) {
super(message);
}
override get name(): string {
return 'MongoTransactionError';
}
}
/**
* An error generated when the user attempts to operate
* on a session that has expired or has been closed.
*
* @public
* @category Error
*/
export class MongoExpiredSessionError extends MongoAPIError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message = 'Cannot use a session that has ended') {
super(message);
}
override get name(): string {
return 'MongoExpiredSessionError';
}
}
/**
* A error generated when the user attempts to authenticate
* via Kerberos, but fails to connect to the Kerberos client.
*
* @public
* @category Error
*/
export class MongoKerberosError extends MongoRuntimeError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string) {
super(message);
}
override get name(): string {
return 'MongoKerberosError';
}
}
/**
* A error generated when the user attempts to authenticate
* via AWS, but fails
*
* @public
* @category Error
*/
export class MongoAWSError extends MongoRuntimeError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string) {
super(message);
}
override get name(): string {
return 'MongoAWSError';
}
}
/**
* A error generated when the user attempts to authenticate
* via Azure, but fails.
*
* @public
* @category Error
*/
export class MongoAzureError extends MongoRuntimeError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string) {
super(message);
}
override get name(): string {
return 'MongoAzureError';
}
}
/**
* An error generated when a ChangeStream operation fails to execute.
*
* @public
* @category Error
*/
export class MongoChangeStreamError extends MongoRuntimeError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string) {
super(message);
}
override get name(): string {
return 'MongoChangeStreamError';
}
}
/**
* An error thrown when the user calls a function or method not supported on a tailable cursor
*
* @public
* @category Error
*/
export class MongoTailableCursorError extends MongoAPIError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message = 'Tailable cursor does not support this operation') {
super(message);
}
override get name(): string {
return 'MongoTailableCursorError';
}
}
/** An error generated when a GridFSStream operation fails to execute.
*
* @public
* @category Error
*/
export class MongoGridFSStreamError extends MongoRuntimeError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string) {
super(message);
}
override get name(): string {
return 'MongoGridFSStreamError';
}
}
/**
* An error generated when a malformed or invalid chunk is
* encountered when reading from a GridFSStream.
*
* @public
* @category Error
*/
export class MongoGridFSChunkError extends MongoRuntimeError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string) {
super(message);
}
override get name(): string {
return 'MongoGridFSChunkError';
}
}
/**
* An error generated when a **parsable** unexpected response comes from the server.
* This is generally an error where the driver in a state expecting a certain behavior to occur in
* the next message from MongoDB but it receives something else.
* This error **does not** represent an issue with wire message formatting.
*
* #### Example
* When an operation fails, it is the driver's job to retry it. It must perform serverSelection
* again to make sure that it attempts the operation against a server in a good state. If server
* selection returns a server that does not support retryable operations, this error is used.
* This scenario is unlikely as retryable support would also have been determined on the first attempt
* but it is possible the state change could report a selectable server that does not support retries.
*
* @public
* @category Error
*/
export class MongoUnexpectedServerResponseError extends MongoRuntimeError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string) {
super(message);
}
override get name(): string {
return 'MongoUnexpectedServerResponseError';
}
}
/**
* An error thrown when the user attempts to add options to a cursor that has already been
* initialized
*
* @public
* @category Error
*/
export class MongoCursorInUseError extends MongoAPIError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message = 'Cursor is already initialized') {
super(message);
}
override get name(): string {
return 'MongoCursorInUseError';
}
}
/**
* An error generated when an attempt is made to operate
* on a closed/closing server.
*
* @public
* @category Error
*/
export class MongoServerClosedError extends MongoAPIError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message = 'Server is closed') {
super(message);
}
override get name(): string {
return 'MongoServerClosedError';
}
}
/**
* An error thrown when an attempt is made to read from a cursor that has been exhausted
*
* @public
* @category Error
*/
export class MongoCursorExhaustedError extends MongoAPIError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message?: string) {
super(message || 'Cursor is exhausted');
}
override get name(): string {
return 'MongoCursorExhaustedError';
}
}
/**
* An error generated when an attempt is made to operate on a
* dropped, or otherwise unavailable, database.
*
* @public
* @category Error
*/
export class MongoTopologyClosedError extends MongoAPIError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message = 'Topology is closed') {
super(message);
}
override get name(): string {
return 'MongoTopologyClosedError';
}
}
/** @internal */
const kBeforeHandshake = Symbol('beforeHandshake');
export function isNetworkErrorBeforeHandshake(err: MongoNetworkError): boolean {
return err[kBeforeHandshake] === true;
}
/** @public */
export interface MongoNetworkErrorOptions {
/** Indicates the timeout happened before a connection handshake completed */
beforeHandshake?: boolean;
cause?: Error;
}
/**
* An error indicating an issue with the network, including TCP errors and timeouts.
* @public
* @category Error
*/
export class MongoNetworkError extends MongoError {
/** @internal */
[kBeforeHandshake]?: boolean;
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string, options?: MongoNetworkErrorOptions) {
super(message, { cause: options?.cause });
if (options && typeof options.beforeHandshake === 'boolean') {
this[kBeforeHandshake] = options.beforeHandshake;
}
}
override get name(): string {
return 'MongoNetworkError';
}
}
/**
* An error indicating a network timeout occurred
* @public
* @category Error
*
* @privateRemarks
* mongodb-client-encryption has a dependency on this error with an instanceof check
*/
export class MongoNetworkTimeoutError extends MongoNetworkError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string, options?: MongoNetworkErrorOptions) {
super(message, options);
}
override get name(): string {
return 'MongoNetworkTimeoutError';
}
}
/**
* An error used when attempting to parse a value (like a connection string)
* @public
* @category Error
*/
export class MongoParseError extends MongoDriverError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string) {
super(message);
}
override get name(): string {
return 'MongoParseError';
}
}
/**
* An error generated when the user supplies malformed or unexpected arguments
* or when a required argument or field is not provided.
*
*
* @public
* @category Error
*/
export class MongoInvalidArgumentError extends MongoAPIError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string) {
super(message);
}
override get name(): string {
return 'MongoInvalidArgumentError';
}
}
/**
* An error generated when a feature that is not enabled or allowed for the current server
* configuration is used
*
*
* @public
* @category Error
*/
export class MongoCompatibilityError extends MongoAPIError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string) {
super(message);
}
override get name(): string {
return 'MongoCompatibilityError';
}
}
/**
* An error generated when the user fails to provide authentication credentials before attempting
* to connect to a mongo server instance.
*
*
* @public
* @category Error
*/
export class MongoMissingCredentialsError extends MongoAPIError {
/**
* **Do not use this constructor!**
*
* Meant for internal use only.
*
* @remarks
* This class is only meant to be constructed within the driver. This constructor is
* not subject to semantic versioning compatibility guarantees and may change at any time.
*
* @public
**/
constructor(message: string) {
super(message);
}
override get name(): string {
return 'MongoMissingCredentialsError';
}
}
/**
* An error generated when a required module or dependency is not present in the local environment
*
* @public
* @category Error
*/
export class MongoMissingDependencyError extends MongoAPIError {
/**
* **Do not use this constructor!**
*