-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
errors.ts
59 lines (50 loc) · 1.62 KB
/
errors.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
import { MongoDriverError, MongoNetworkError } from '../error';
import type { ConnectionPool } from './connection_pool';
/**
* An error indicating a connection pool is closed
* @category Error
*/
export class PoolClosedError extends MongoDriverError {
/** The address of the connection pool */
address: string;
constructor(pool: ConnectionPool) {
super('Attempted to check out a connection from closed connection pool');
this.address = pool.address;
}
override get name(): string {
return 'MongoPoolClosedError';
}
}
/**
* An error indicating a connection pool is currently paused
* @category Error
*/
export class PoolClearedError extends MongoNetworkError {
// TODO(NODE-3144): needs to extend RetryableError or be marked retryable in some other way per spec
/** The address of the connection pool */
address: string;
constructor(pool: ConnectionPool) {
// TODO(NODE-3135): pass in original pool-clearing error and use in message
// "failed with: <original error which cleared the pool>"
super(`Connection pool for ${pool.address} was cleared because another operation failed`);
this.address = pool.address;
}
override get name(): string {
return 'MongoPoolClearedError';
}
}
/**
* An error thrown when a request to check out a connection times out
* @category Error
*/
export class WaitQueueTimeoutError extends MongoDriverError {
/** The address of the connection pool */
address: string;
constructor(message: string, address: string) {
super(message);
this.address = address;
}
override get name(): string {
return 'MongoWaitQueueTimeoutError';
}
}