Skip to content

Commit b18c0e7

Browse files
authored
🤖 Merge PR DefinitelyTyped#74802 [mssql] change MSSQL error code enum to union of string literals by @erehulka
1 parent 54b3195 commit b18c0e7

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

‎types/mssql/index.d.ts‎

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -216,28 +216,27 @@ export interface config {
216216
beforeConnect?: ((conn: Connection) => void) | undefined;
217217
}
218218

219-
export declare enum MSSQL_ERROR_CODE {
220-
ELOGIN = "ELOGIN",
221-
ETIMEOUT = "ETIMEOUT",
222-
EDRIVER = "EDRIVER",
223-
EALREADYCONNECTED = "EALREADYCONNECTED",
224-
EALREADYCONNECTING = "EALREADYCONNECTING",
225-
ENOTOPEN = "ENOTOPEN",
226-
EINSTLOOKUP = "EINSTLOOKUP",
227-
ESOCKET = "ESOCKET",
228-
ECONNCLOSED = "ECONNCLOSED",
229-
ENOTBEGUN = "ENOTBEGUN",
230-
EALREADYBEGUN = "EALREADYBEGUN",
231-
EREQINPROG = "EREQINPROG",
232-
EABORT = "EABORT",
233-
EREQUEST = "EREQUEST",
234-
ECANCEL = "ECANCEL",
235-
EARGS = "EARGS",
236-
EINJECT = "EINJECT",
237-
ENOCONN = "ENOCONN",
238-
EALREADYPREPARED = "EALREADYPREPARED",
239-
ENOTPREPARED = "ENOTPREPARED",
240-
}
219+
export type MSSQL_ERROR_CODE =
220+
| "ELOGIN"
221+
| "ETIMEOUT"
222+
| "EDRIVER"
223+
| "EALREADYCONNECTED"
224+
| "EALREADYCONNECTING"
225+
| "ENOTOPEN"
226+
| "EINSTLOOKUP"
227+
| "ESOCKET"
228+
| "ECONNCLOSED"
229+
| "ENOTBEGUN"
230+
| "EALREADYBEGUN"
231+
| "EREQINPROG"
232+
| "EABORT"
233+
| "EREQUEST"
234+
| "ECANCEL"
235+
| "EARGS"
236+
| "EINJECT"
237+
| "ENOCONN"
238+
| "EALREADYPREPARED"
239+
| "ENOTPREPARED";
241240

242241
export declare class MSSQLError extends Error {
243242
constructor(message: Error | string, code?: MSSQL_ERROR_CODE);

‎types/mssql/mssql-tests.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,11 @@ function test_mssql_errors() {
320320
// Test constructors
321321
const sqlDriverError = new Error("mock error");
322322
const mssqlStringError = new sql.MSSQLError("Something went wrong");
323-
const baseMSSQLError = new sql.MSSQLError(sqlDriverError, sql.MSSQL_ERROR_CODE.EREQUEST);
324-
const connectionError = new sql.ConnectionError(sqlDriverError, sql.MSSQL_ERROR_CODE.ELOGIN);
325-
const requestError = new sql.RequestError(sqlDriverError, sql.MSSQL_ERROR_CODE.EREQUEST);
326-
const preparedStatementError = new sql.PreparedStatementError(sqlDriverError, sql.MSSQL_ERROR_CODE.EINJECT);
327-
const transactionError = new sql.TransactionError(sqlDriverError, sql.MSSQL_ERROR_CODE.EABORT);
323+
const baseMSSQLError = new sql.MSSQLError(sqlDriverError, "EREQUEST");
324+
const connectionError = new sql.ConnectionError(sqlDriverError, "ELOGIN");
325+
const requestError = new sql.RequestError(sqlDriverError, "EREQUEST");
326+
const preparedStatementError = new sql.PreparedStatementError(sqlDriverError, "EINJECT");
327+
const transactionError = new sql.TransactionError(sqlDriverError, "EABORT");
328328

329329
// Test inheritance
330330
if (

0 commit comments

Comments
 (0)