@@ -202,7 +202,6 @@ export class MongoRuntimeError extends MongoDriverError {
202202 * An error generated when a batch command is reexecuted after one of the commands in the batch
203203 * has failed
204204 *
205- *
206205 * @public
207206 * @category Error
208207 */
@@ -216,11 +215,60 @@ export class MongoBatchReExecutionError extends MongoRuntimeError {
216215 }
217216}
218217
218+ /**
219+ * An error generated when the user supplies an incorrect URI to the driver.
220+ *
221+ * @public
222+ * @category Error
223+ */
224+ export class MongoURIError extends MongoRuntimeError {
225+ constructor ( message : string ) {
226+ super ( message ) ;
227+ }
228+
229+ get name ( ) : string {
230+ return 'MongoURIError' ;
231+ }
232+ }
233+
234+ /**
235+ * An error generated when the driver fails to compress data
236+ * before sending it to the server.
237+ *
238+ * @public
239+ * @category Error
240+ */
241+ export class MongoCompressionError extends MongoRuntimeError {
242+ constructor ( message : string ) {
243+ super ( message ) ;
244+ }
245+
246+ get name ( ) : string {
247+ return 'MongoCompressionError' ;
248+ }
249+ }
250+
251+ /**
252+ * An error generated when the driver fails to decompress
253+ * data received from the server.
254+ *
255+ * @public
256+ * @category Error
257+ */
258+ export class MongoDecompressionError extends MongoRuntimeError {
259+ constructor ( message : string ) {
260+ super ( message ) ;
261+ }
262+
263+ get name ( ) : string {
264+ return 'MongoDecompressionError' ;
265+ }
266+ }
267+
219268/**
220269 * An error thrown when the user attempts to operate on a database or collection through a MongoClient
221270 * that has not yet successfully called the "connect" method
222271 *
223- *
224272 * @public
225273 * @category Error
226274 */
@@ -234,11 +282,61 @@ export class MongoNotConnectedError extends MongoRuntimeError {
234282 }
235283}
236284
285+ /**
286+ * An error generated when the user makes a mistake in the usage of transactions.
287+ * (e.g. attempting to commit a transaction with a readPreference other than primary)
288+ *
289+ * @public
290+ * @category Error
291+ */
292+ export class MongoTransactionError extends MongoRuntimeError {
293+ constructor ( message : string ) {
294+ super ( message ) ;
295+ }
296+
297+ get name ( ) : string {
298+ return 'MongoTransactionError' ;
299+ }
300+ }
301+
302+ /**
303+ * An error generated when the user attempts to operate
304+ * on a session that has expired or has been closed.
305+ *
306+ * @public
307+ * @category Error
308+ */
309+ export class MongoExpiredSessionError extends MongoRuntimeError {
310+ constructor ( message : string ) {
311+ super ( message ) ;
312+ }
313+
314+ get name ( ) : string {
315+ return 'MongoExpiredSessionError' ;
316+ }
317+ }
318+
319+ /**
320+ * A error generated when the user attempts to authenticate
321+ * via Kerberos, but fails to connect to the Kerberos client.
322+ *
323+ * @public
324+ * @category Error
325+ */
326+ export class MongoKerberosError extends MongoRuntimeError {
327+ constructor ( message : string ) {
328+ super ( message ) ;
329+ }
330+
331+ get name ( ) : string {
332+ return 'MongoKerberosError' ;
333+ }
334+ }
335+
237336/**
238337 * An error thrown when the user attempts to operate on a cursor that is in a state which does not
239338 * support the attempted operation.
240339 *
241- *
242340 * @public
243341 * @category Error
244342 */
@@ -253,8 +351,39 @@ export class MongoCursorError extends MongoRuntimeError {
253351}
254352
255353/**
256- * An error thrown when the user calls a function or method not supported on a tailable cursor
354+ * An error generated when a stream operation fails to execute.
257355 *
356+ * @public
357+ * @category Error
358+ */
359+ export class MongoStreamError extends MongoRuntimeError {
360+ constructor ( message : string ) {
361+ super ( message ) ;
362+ }
363+
364+ get name ( ) : string {
365+ return 'MongoStreamError' ;
366+ }
367+ }
368+
369+ /**
370+ * An error generated when a ChangeStream operation fails to execute.
371+ *
372+ * @public
373+ * @category Error
374+ */
375+ export class MongoChangeStreamError extends MongoStreamError {
376+ constructor ( message : string ) {
377+ super ( message ) ;
378+ }
379+
380+ get name ( ) : string {
381+ return 'MongoChangeStreamError' ;
382+ }
383+ }
384+
385+ /**
386+ * An error thrown when the user calls a function or method not supported on a tailable cursor
258387 *
259388 * @public
260389 * @category Error
@@ -269,11 +398,42 @@ export class MongoTailableCursorError extends MongoCursorError {
269398 }
270399}
271400
401+ /** An error generated when a GridFSStream operation fails to execute.
402+ *
403+ * @public
404+ * @category Error
405+ */
406+ export class MongoGridFSStreamError extends MongoStreamError {
407+ constructor ( message : string ) {
408+ super ( message ) ;
409+ }
410+
411+ get name ( ) : string {
412+ return 'MongoGridFSStreamError' ;
413+ }
414+ }
415+
416+ /**
417+ * An error generated when a malformed or invalid chunk is
418+ * encountered when reading from a GridFSStream.
419+ *
420+ * @public
421+ * @category Error
422+ */
423+ export class MongoGridFSChunkError extends MongoStreamError {
424+ constructor ( message : string ) {
425+ super ( message ) ;
426+ }
427+
428+ get name ( ) : string {
429+ return 'MongoGridFSChunkError' ;
430+ }
431+ }
432+
272433/**
273434 * An error thrown when the user attempts to add options to a cursor that has already been
274435 * initialized
275436 *
276- *
277437 * @public
278438 * @category Error
279439 */
@@ -288,8 +448,41 @@ export class MongoCursorInUseError extends MongoCursorError {
288448}
289449
290450/**
291- * An error thrown when an attempt is made to read from a cursor that has been exhausted
451+ * An error generated when an attempt is made to access a resource
452+ * which has already been or will be closed/destroyed.
292453 *
454+ * @public
455+ * @category Error
456+ */
457+ export class MongoResourceClosedError extends MongoRuntimeError {
458+ constructor ( message : string ) {
459+ super ( message ) ;
460+ }
461+
462+ get name ( ) : string {
463+ return 'MongoResourceClosedError' ;
464+ }
465+ }
466+
467+ /**
468+ * An error generated when an attempt is made to operate
469+ * on a closed/closing server.
470+ *
471+ * @public
472+ * @category Error
473+ */
474+ export class MongoServerClosedError extends MongoResourceClosedError {
475+ constructor ( message : string ) {
476+ super ( message ) ;
477+ }
478+
479+ get name ( ) : string {
480+ return 'MongoServerClosedError' ;
481+ }
482+ }
483+
484+ /**
485+ * An error thrown when an attempt is made to read from a cursor that has been exhausted
293486 *
294487 * @public
295488 * @category Error
@@ -304,6 +497,40 @@ export class MongoCursorExhaustedError extends MongoCursorError {
304497 }
305498}
306499
500+ /**
501+ * An error generated when an attempt is made to operate
502+ * on a closed/closing stream.
503+ *
504+ * @public
505+ * @category Error
506+ */
507+ export class MongoStreamClosedError extends MongoResourceClosedError {
508+ constructor ( message : string ) {
509+ super ( message ) ;
510+ }
511+
512+ get name ( ) : string {
513+ return 'MongoStreamClosedError' ;
514+ }
515+ }
516+
517+ /**
518+ * An error generated when an attempt is made to operate on a
519+ * dropped, or otherwise unavailable, database.
520+ *
521+ * @public
522+ * @category Error
523+ */
524+ export class MongoTopologyClosedError extends MongoResourceClosedError {
525+ constructor ( message : string ) {
526+ super ( message ) ;
527+ }
528+
529+ get name ( ) : string {
530+ return 'MongoTopologyClosedError' ;
531+ }
532+ }
533+
307534/** @internal */
308535const kBeforeHandshake = Symbol ( 'beforeHandshake' ) ;
309536export function isNetworkErrorBeforeHandshake ( err : MongoNetworkError ) : boolean {
0 commit comments