mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
Merge pull request #813 from Tria-plc/alpha
debug(passenger-api): expose Prisma error code in 500 response body
This commit is contained in:
@@ -24,7 +24,11 @@ export class HttpExceptionFilter implements ExceptionFilter {
|
||||
const request = ctx.getRequest();
|
||||
|
||||
let prismaMessage: string | null = null;
|
||||
let prismaCode: string | null = null;
|
||||
let prismaMeta: unknown = null;
|
||||
if (exception instanceof PrismaClientKnownRequestError) {
|
||||
prismaCode = exception.code;
|
||||
prismaMeta = exception.meta;
|
||||
if (exception.code === 'P2003') {
|
||||
const field = (exception.meta?.field_name as string | undefined) ?? 'a related record';
|
||||
prismaMessage = `Cannot delete this record because it is still referenced by ${field}. Remove the related records first.`;
|
||||
@@ -68,6 +72,7 @@ export class HttpExceptionFilter implements ExceptionFilter {
|
||||
statusCode: status,
|
||||
message,
|
||||
error: exception instanceof Error ? exception.name : 'Error',
|
||||
...(prismaCode ? { prismaCode, prismaMeta } : {}),
|
||||
timestamp: new Date().toISOString(),
|
||||
path: request.url,
|
||||
...customFields,
|
||||
|
||||
Reference in New Issue
Block a user