Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 62x 62x 62x 62x 133x 931x 55x 55x | import { BaseError } from './base-error.ts';
/**
* Failure to reach or authenticate against PostgreSQL (Sequelize v6 `ConnectionError`).
*
* Thrown when connecting fails and for driver errors with an unmapped `08xxx` SQLSTATE. The subclasses below narrow the cause; `parent` and `original` hold the driver error.
*
* @example
* ```ts
* try {
* await sequelize.authenticate();
* } catch (e) {
* if (e instanceof ConnectionError) {
* console.error('cannot connect:', e.parent.message);
* }
* }
* ```
*/
export class ConnectionError extends BaseError {
/** Original driver error. */
readonly parent: Error;
/** Original driver error (alias of `parent`). */
readonly original: Error;
/**
* Wraps a driver error; the message and `cause` are taken from it.
*
* @param parent - Original driver error.
*/
constructor(parent: Error) {
super(parent.message, { cause: parent });
this.name = 'SequelizeConnectionError';
this.parent = parent;
this.original = parent;
}
}
const connectionError = (name: string): typeof ConnectionError =>
class extends ConnectionError {
constructor(parent: Error) {
super(parent);
this.name = name;
}
};
/**
* Thrown when the server refuses the connection (`ECONNREFUSED`), typically because PostgreSQL is not running on that host and port.
*
* @example
* ```ts
* try {
* await sequelize.authenticate();
* } catch (e) {
* if (e instanceof ConnectionRefusedError) {
* console.error('database is down');
* }
* }
* ```
*/
export class ConnectionRefusedError extends connectionError('SequelizeConnectionRefusedError') {}
/**
* Thrown when PostgreSQL rejects the credentials (SQLSTATE `28P01` or `28000`).
*
* @example
* ```ts
* try {
* await sequelize.authenticate();
* } catch (e) {
* if (e instanceof AccessDeniedError) {
* console.error('check username and password');
* }
* }
* ```
*/
export class AccessDeniedError extends connectionError('SequelizeAccessDeniedError') {}
/**
* Thrown when the host name cannot be resolved (`ENOTFOUND` or `EAI_AGAIN`).
*
* @example
* ```ts
* try {
* await sequelize.authenticate();
* } catch (e) {
* if (e instanceof HostNotFoundError) {
* console.error('unknown database host');
* }
* }
* ```
*/
export class HostNotFoundError extends connectionError('SequelizeHostNotFoundError') {}
/**
* Thrown when no route to the host exists (`EHOSTUNREACH`).
*
* @example
* ```ts
* try {
* await sequelize.authenticate();
* } catch (e) {
* if (e instanceof HostNotReachableError) {
* console.error('database host is unreachable');
* }
* }
* ```
*/
export class HostNotReachableError extends connectionError('SequelizeHostNotReachableError') {}
/**
* Thrown when the connection parameters are rejected by the network layer (`EINVAL`).
*
* @example
* ```ts
* try {
* await sequelize.authenticate();
* } catch (e) {
* if (e instanceof InvalidConnectionError) {
* console.error('check host and port settings');
* }
* }
* ```
*/
export class InvalidConnectionError extends connectionError('SequelizeInvalidConnectionError') {}
/**
* Thrown when the TCP connection to the server times out (`ETIMEDOUT`).
*
* @example
* ```ts
* try {
* await sequelize.authenticate();
* } catch (e) {
* if (e instanceof ConnectionTimedOutError) {
* console.error('database did not answer in time');
* }
* }
* ```
*/
export class ConnectionTimedOutError extends connectionError('SequelizeConnectionTimedOutError') {}
/**
* Thrown when no pooled connection became free within `pool.acquire` milliseconds (default 60000).
*
* Raise `pool.max` or shorten the transactions that hold connections.
* See {@link PoolOptions}.
*
* @example
* ```ts
* try {
* await User.findAll();
* } catch (e) {
* if (e instanceof ConnectionAcquireTimeoutError) {
* console.error('pool exhausted');
* }
* }
* ```
*/
export class ConnectionAcquireTimeoutError extends connectionError(
'SequelizeConnectionAcquireTimeoutError',
) {}
|