prisma-generator-express 1.34.3 → 1.34.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -115,27 +115,45 @@ export function mapError(error: unknown): HttpError {
|
|
|
115
115
|
const code = (error as any).code as string
|
|
116
116
|
const mapped = PRISMA_ERROR_MAP[code]
|
|
117
117
|
if (mapped) {
|
|
118
|
-
|
|
118
|
+
const detail = (error as any).message
|
|
119
|
+
const message = detail
|
|
120
|
+
? mapped.message + ': ' + detail
|
|
121
|
+
: mapped.message
|
|
122
|
+
return new HttpError(mapped.status, message)
|
|
119
123
|
}
|
|
120
124
|
if (typeof code === 'string' && code.startsWith('P')) {
|
|
125
|
+
const msg = (error as any).message || 'Database operation failed'
|
|
121
126
|
console.warn(
|
|
122
127
|
'[prisma-generator-express] Unmapped Prisma error code:',
|
|
123
128
|
code,
|
|
124
|
-
|
|
129
|
+
msg,
|
|
125
130
|
)
|
|
126
|
-
return new HttpError(500,
|
|
131
|
+
return new HttpError(500, msg)
|
|
127
132
|
}
|
|
128
133
|
}
|
|
129
134
|
|
|
130
135
|
if (error && typeof error === 'object' && 'name' in error) {
|
|
131
136
|
const name = (error as any).name
|
|
132
137
|
if (name === 'PrismaClientValidationError') {
|
|
133
|
-
return new HttpError(400, 'Invalid query parameters')
|
|
138
|
+
return new HttpError(400, (error as any).message || 'Invalid query parameters')
|
|
139
|
+
}
|
|
140
|
+
if (name === 'PrismaClientKnownRequestError') {
|
|
141
|
+
return new HttpError(400, (error as any).message || 'Database request error')
|
|
142
|
+
}
|
|
143
|
+
if (name === 'PrismaClientInitializationError') {
|
|
144
|
+
return new HttpError(503, (error as any).message || 'Database connection failed')
|
|
145
|
+
}
|
|
146
|
+
if (name === 'PrismaClientRustPanicError') {
|
|
147
|
+
return new HttpError(500, (error as any).message || 'Internal database engine error')
|
|
148
|
+
}
|
|
149
|
+
if (name === 'PrismaClientUnknownRequestError') {
|
|
150
|
+
return new HttpError(500, (error as any).message || 'Unknown database error')
|
|
134
151
|
}
|
|
135
152
|
}
|
|
136
153
|
|
|
154
|
+
const msg = error instanceof Error ? error.message : String(error)
|
|
137
155
|
console.error('[prisma-generator-express] Unhandled error:', error)
|
|
138
|
-
return new HttpError(500, 'Internal server error')
|
|
156
|
+
return new HttpError(500, msg || 'Internal server error')
|
|
139
157
|
}
|
|
140
158
|
|
|
141
159
|
let _speedExtension: ((opts: any) => any) | null = null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateOperationCore.js","sourceRoot":"","sources":["../../src/generators/generateOperationCore.ts"],"names":[],"mappings":";;AAEA,
|
|
1
|
+
{"version":3,"file":"generateOperationCore.js","sourceRoot":"","sources":["../../src/generators/generateOperationCore.ts"],"names":[],"mappings":";;AAEA,4DAuXC;AAMD,8CAmLC;AAhjBD,SAAgB,wBAAwB;IACtC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqXR,CAAA;AACD,CAAC;AAMD,SAAgB,iBAAiB,CAAC,OAAyB;IACzD,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAA;IACpC,MAAM,cAAc,GAClB,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,C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;YAChB,cAAc,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC;SAC9C;KACF,CAAA;IAED,MAAM,aAAa,GAAG,QAAQ;SAC3B,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;QACV,MAAM,eAAe,GAAG,EAAE,CAAC,cAAc;aACtC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,6BAA6B,KAAK,IAAI,CAAC;aACtD,IAAI,CAAC,IAAI,CAAC,CAAA;QAEb,OAAO;wBACW,EAAE,CAAC,IAAI;;EAE7B,eAAe;;;oCAGmB,cAAc;+BACnB,cAAc,2CAA2C,EAAE,CAAC,MAAM;;6BAEpE,cAAc,IAAI,EAAE,CAAC,MAAM;EACtD,CAAA;IACE,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAA;IAEb,OAAO;;;;;;;;;;;;;;;oCAe2B,cAAc;+BACnB,cAAc;;6BAEhB,cAAc;;EAEzC,oBAAoB;EACpB,aAAa;;;;;;;;;;;;;oCAaqB,cAAc;;;;;;;;;;uBAU3B,cAAc;uBACd,cAAc;gDACW,cAAc;;;;;;;;;;;;;;sCAcxB,cAAc;sCACd,cAAc;;8BAEtB,cAAc;;;;;;;;;;;;kCAYV,cAAc;kCACd,cAAc;;0BAEtB,cAAc;;;;;;;;;;;;;;CAcvC,CAAA;AACD,CAAC"}
|
package/package.json
CHANGED
|
@@ -113,27 +113,45 @@ export function mapError(error: unknown): HttpError {
|
|
|
113
113
|
const code = (error as any).code as string
|
|
114
114
|
const mapped = PRISMA_ERROR_MAP[code]
|
|
115
115
|
if (mapped) {
|
|
116
|
-
|
|
116
|
+
const detail = (error as any).message
|
|
117
|
+
const message = detail
|
|
118
|
+
? mapped.message + ': ' + detail
|
|
119
|
+
: mapped.message
|
|
120
|
+
return new HttpError(mapped.status, message)
|
|
117
121
|
}
|
|
118
122
|
if (typeof code === 'string' && code.startsWith('P')) {
|
|
123
|
+
const msg = (error as any).message || 'Database operation failed'
|
|
119
124
|
console.warn(
|
|
120
125
|
'[prisma-generator-express] Unmapped Prisma error code:',
|
|
121
126
|
code,
|
|
122
|
-
|
|
127
|
+
msg,
|
|
123
128
|
)
|
|
124
|
-
return new HttpError(500,
|
|
129
|
+
return new HttpError(500, msg)
|
|
125
130
|
}
|
|
126
131
|
}
|
|
127
132
|
|
|
128
133
|
if (error && typeof error === 'object' && 'name' in error) {
|
|
129
134
|
const name = (error as any).name
|
|
130
135
|
if (name === 'PrismaClientValidationError') {
|
|
131
|
-
return new HttpError(400, 'Invalid query parameters')
|
|
136
|
+
return new HttpError(400, (error as any).message || 'Invalid query parameters')
|
|
137
|
+
}
|
|
138
|
+
if (name === 'PrismaClientKnownRequestError') {
|
|
139
|
+
return new HttpError(400, (error as any).message || 'Database request error')
|
|
140
|
+
}
|
|
141
|
+
if (name === 'PrismaClientInitializationError') {
|
|
142
|
+
return new HttpError(503, (error as any).message || 'Database connection failed')
|
|
143
|
+
}
|
|
144
|
+
if (name === 'PrismaClientRustPanicError') {
|
|
145
|
+
return new HttpError(500, (error as any).message || 'Internal database engine error')
|
|
146
|
+
}
|
|
147
|
+
if (name === 'PrismaClientUnknownRequestError') {
|
|
148
|
+
return new HttpError(500, (error as any).message || 'Unknown database error')
|
|
132
149
|
}
|
|
133
150
|
}
|
|
134
151
|
|
|
152
|
+
const msg = error instanceof Error ? error.message : String(error)
|
|
135
153
|
console.error('[prisma-generator-express] Unhandled error:', error)
|
|
136
|
-
return new HttpError(500, 'Internal server error')
|
|
154
|
+
return new HttpError(500, msg || 'Internal server error')
|
|
137
155
|
}
|
|
138
156
|
|
|
139
157
|
let _speedExtension: ((opts: any) => any) | null = null
|