( cause: unknown, message: string, operation: string )
| 96 | } |
| 97 | |
| 98 | const classifyError = ( |
| 99 | cause: unknown, |
| 100 | message: string, |
| 101 | operation: string |
| 102 | ) => { |
| 103 | const props = { cause, message, operation } |
| 104 | const errno = mysqlErrnoFromCause(cause) |
| 105 | if (errno !== undefined) { |
| 106 | if (mysqlConnectionErrorCodes.has(errno)) { |
| 107 | return new ConnectionError(props) |
| 108 | } |
| 109 | if (errno === 1045) { |
| 110 | return new AuthenticationError(props) |
| 111 | } |
| 112 | if (mysqlAuthorizationErrorCodes.has(errno)) { |
| 113 | return new AuthorizationError(props) |
| 114 | } |
| 115 | if (mysqlSyntaxErrorCodes.has(errno)) { |
| 116 | return new SqlSyntaxError(props) |
| 117 | } |
| 118 | if (errno === 1062) { |
| 119 | return new UniqueViolation({ ...props, constraint: mysqlDuplicateEntryConstraintFromCause(cause) }) |
| 120 | } |
| 121 | if (mysqlConstraintErrorCodes.has(errno)) { |
| 122 | return new ConstraintError(props) |
| 123 | } |
| 124 | if (errno === 1213) { |
| 125 | return new DeadlockError(props) |
| 126 | } |
| 127 | if (errno === 1205) { |
| 128 | return new LockTimeoutError(props) |
| 129 | } |
| 130 | if (errno === 3024) { |
| 131 | return new StatementTimeoutError(props) |
| 132 | } |
| 133 | } |
| 134 | return new UnknownError(props) |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Runtime type identifier used to mark `MysqlClient` values. |
no test coverage detected
searching dependent graphs…