Compare commits

...

2 Commits

2 changed files with 7 additions and 2 deletions

View File

@ -28,6 +28,11 @@ export function handlePrismaError(errorObj: any, res: Response, source: string)
res.status(404).json({ status: 'ERROR', errorcode: 'DB_ERROR', message: 'Relation object does not exist', meta: errorObj.meta }); res.status(404).json({ status: 'ERROR', errorcode: 'DB_ERROR', message: 'Relation object does not exist', meta: errorObj.meta });
break; break;
// P2025 -> "An operation failed because it depends on one or more records that were required but not found. {cause}"
case 'P2025':
res.status(404).json({ status: 'ERROR', errorcode: 'DB_ERROR', message: 'Object does not exist', meta: errorObj.meta });
break;
default: default:
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', message: 'An error occurred during the database operation' }); res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', message: 'An error occurred during the database operation' });
break; break;

View File

@ -13,8 +13,8 @@ async function get(req: Request, res: Response) {
} else { } else {
log.api?.debug('GET products Success:', req.query, value); log.api?.debug('GET products Success:', req.query, value);
if (value.search !== undefined || value.id !== undefined) { if (value.search !== undefined || value.id !== undefined || value.gtin !== undefined) {
// if search or get by id // if search or get by id/gtin
await db await db
.$transaction([ .$transaction([
// Same query for count and findMany // Same query for count and findMany