@prisma-next/sql-errors
Advanced tools
| export interface SqlDriverError<Kind extends string> { | ||
| readonly kind: Kind; | ||
| } | ||
| /** | ||
| * SQL query error for query-related failures (syntax errors, constraint violations, permissions). | ||
| */ | ||
| export declare class SqlQueryError extends Error implements SqlDriverError<'sql_query'> { | ||
| static readonly ERROR_NAME: "SqlQueryError"; | ||
| readonly kind: "sql_query"; | ||
| readonly sqlState: string | undefined; | ||
| readonly constraint: string | undefined; | ||
| readonly table: string | undefined; | ||
| readonly column: string | undefined; | ||
| readonly detail: string | undefined; | ||
| constructor(message: string, options?: { | ||
| readonly cause?: Error; | ||
| readonly sqlState?: string; | ||
| readonly constraint?: string; | ||
| readonly table?: string; | ||
| readonly column?: string; | ||
| readonly detail?: string; | ||
| }); | ||
| /** | ||
| * Type predicate to check if an error is a SqlQueryError. | ||
| */ | ||
| static is(error: unknown): error is SqlQueryError; | ||
| } | ||
| /** | ||
| * SQL connection error (timeouts, connection resets, etc.). | ||
| */ | ||
| export declare class SqlConnectionError extends Error implements SqlDriverError<'sql_connection'> { | ||
| static readonly ERROR_NAME: "SqlConnectionError"; | ||
| readonly kind: "sql_connection"; | ||
| readonly transient: boolean | undefined; | ||
| constructor(message: string, options?: { | ||
| readonly cause?: Error; | ||
| readonly transient?: boolean; | ||
| }); | ||
| /** | ||
| * Type predicate to check if an error is a SqlConnectionError. | ||
| */ | ||
| static is(error: unknown): error is SqlConnectionError; | ||
| } | ||
| //# sourceMappingURL=errors.d.ts.map |
| {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc,CAAC,IAAI,SAAS,MAAM;IACjD,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB;AACD;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAM,YAAW,cAAc,CAAC,WAAW,CAAC;IAC7E,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAG,eAAe,CAAU;IACtD,QAAQ,CAAC,IAAI,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
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"} |
| export interface SqlDriverError<Kind extends string> { | ||
| readonly kind: Kind; | ||
| } | ||
| /** | ||
| * SQL query error for query-related failures (syntax errors, constraint violations, permissions). | ||
| */ | ||
| export class SqlQueryError extends Error implements SqlDriverError<'sql_query'> { | ||
| static readonly ERROR_NAME = 'SqlQueryError' as const; | ||
| readonly kind = 'sql_query' as const; | ||
| readonly sqlState: string | undefined; | ||
| readonly constraint: string | undefined; | ||
| readonly table: string | undefined; | ||
| readonly column: string | undefined; | ||
| readonly detail: string | undefined; | ||
| constructor( | ||
| message: string, | ||
| options?: { | ||
| readonly cause?: Error; | ||
| readonly sqlState?: string; | ||
| readonly constraint?: string; | ||
| readonly table?: string; | ||
| readonly column?: string; | ||
| readonly detail?: string; | ||
| }, | ||
| ) { | ||
| super(message, { cause: options?.cause }); | ||
| this.name = SqlQueryError.ERROR_NAME; | ||
| this.sqlState = options?.sqlState; | ||
| this.constraint = options?.constraint; | ||
| this.table = options?.table; | ||
| this.column = options?.column; | ||
| this.detail = options?.detail; | ||
| } | ||
| /** | ||
| * Type predicate to check if an error is a SqlQueryError. | ||
| */ | ||
| static is(error: unknown): error is SqlQueryError { | ||
| return ( | ||
| typeof error === 'object' && | ||
| error !== null && | ||
| Object.hasOwn(error, 'kind') && | ||
| (error as { kind: unknown }).kind === 'sql_query' | ||
| ); | ||
| } | ||
| } | ||
| /** | ||
| * SQL connection error (timeouts, connection resets, etc.). | ||
| */ | ||
| export class SqlConnectionError extends Error implements SqlDriverError<'sql_connection'> { | ||
| static readonly ERROR_NAME = 'SqlConnectionError' as const; | ||
| readonly kind = 'sql_connection' as const; | ||
| readonly transient: boolean | undefined; | ||
| constructor( | ||
| message: string, | ||
| options?: { | ||
| readonly cause?: Error; | ||
| readonly transient?: boolean; | ||
| }, | ||
| ) { | ||
| super(message, { cause: options?.cause }); | ||
| this.name = SqlConnectionError.ERROR_NAME; | ||
| this.transient = options?.transient; | ||
| } | ||
| /** | ||
| * Type predicate to check if an error is a SqlConnectionError. | ||
| */ | ||
| static is(error: unknown): error is SqlConnectionError { | ||
| return ( | ||
| typeof error === 'object' && | ||
| error !== null && | ||
| Object.hasOwn(error, 'kind') && | ||
| (error as { kind: unknown }).kind === 'sql_connection' | ||
| ); | ||
| } | ||
| } |
| export { SqlConnectionError, SqlQueryError } from '../errors'; |
@@ -1,45 +0,2 @@ | ||
| interface SqlDriverError<Kind extends string> { | ||
| readonly kind: Kind; | ||
| } | ||
| /** | ||
| * SQL query error for query-related failures (syntax errors, constraint violations, permissions). | ||
| */ | ||
| declare class SqlQueryError extends Error implements SqlDriverError<'sql_query'> { | ||
| static readonly ERROR_NAME: "SqlQueryError"; | ||
| readonly kind: "sql_query"; | ||
| readonly sqlState: string | undefined; | ||
| readonly constraint: string | undefined; | ||
| readonly table: string | undefined; | ||
| readonly column: string | undefined; | ||
| readonly detail: string | undefined; | ||
| constructor(message: string, options?: { | ||
| readonly cause?: Error; | ||
| readonly sqlState?: string; | ||
| readonly constraint?: string; | ||
| readonly table?: string; | ||
| readonly column?: string; | ||
| readonly detail?: string; | ||
| }); | ||
| /** | ||
| * Type predicate to check if an error is a SqlQueryError. | ||
| */ | ||
| static is(error: unknown): error is SqlQueryError; | ||
| } | ||
| /** | ||
| * SQL connection error (timeouts, connection resets, etc.). | ||
| */ | ||
| declare class SqlConnectionError extends Error implements SqlDriverError<'sql_connection'> { | ||
| static readonly ERROR_NAME: "SqlConnectionError"; | ||
| readonly kind: "sql_connection"; | ||
| readonly transient: boolean | undefined; | ||
| constructor(message: string, options?: { | ||
| readonly cause?: Error; | ||
| readonly transient?: boolean; | ||
| }); | ||
| /** | ||
| * Type predicate to check if an error is a SqlConnectionError. | ||
| */ | ||
| static is(error: unknown): error is SqlConnectionError; | ||
| } | ||
| export { SqlConnectionError, SqlQueryError }; | ||
| export { SqlConnectionError, SqlQueryError } from '../errors'; | ||
| //# sourceMappingURL=index.d.ts.map |
+8
-7
| { | ||
| "name": "@prisma-next/sql-errors", | ||
| "version": "0.3.0-pr.73.2", | ||
| "version": "0.3.0-pr.75.1", | ||
| "type": "module", | ||
@@ -9,10 +9,11 @@ "sideEffects": false, | ||
| "devDependencies": { | ||
| "@vitest/coverage-v8": "^4.0.0", | ||
| "tsup": "^8.3.0", | ||
| "typescript": "^5.9.3", | ||
| "vitest": "^4.0.16", | ||
| "@vitest/coverage-v8": "4.0.16", | ||
| "tsup": "8.5.1", | ||
| "typescript": "5.9.3", | ||
| "vitest": "4.0.16", | ||
| "@prisma-next/test-utils": "0.0.1" | ||
| }, | ||
| "files": [ | ||
| "dist" | ||
| "dist", | ||
| "src" | ||
| ], | ||
@@ -26,3 +27,3 @@ "exports": { | ||
| "scripts": { | ||
| "build": "tsup --config tsup.config.ts", | ||
| "build": "tsup --config tsup.config.ts && tsc --project tsconfig.json --rootDir src --outDir dist --declaration --declarationMap --emitDeclarationOnly", | ||
| "test": "vitest run", | ||
@@ -29,0 +30,0 @@ "test:coverage": "vitest run --coverage", |
13893
42.03%10
100%165
85.39%