This commit is contained in:
Sören Oesterwind 2023-07-10 18:00:24 +02:00
parent ea80b4bf2b
commit 421085a8d5
4 changed files with 36 additions and 0 deletions

View File

@ -122,6 +122,10 @@ function post(req: Request, res: Response) {
// P2002 -> "Unique constraint failed on the {constraint}" // P2002 -> "Unique constraint failed on the {constraint}"
// https://www.prisma.io/docs/reference/api-reference/error-reference // https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(409).json({ status: 'ERROR', errorcode: 'EXISTING', message: 'Category already exists' }); res.status(409).json({ status: 'ERROR', errorcode: 'EXISTING', message: 'Category already exists' });
} else if (err.code == 'P2000') {
// P2000 -> "The provided value for the column is too long for the column's type. Column: {column_name}"
// https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(404).json({ status: 'ERROR', errorcode: 'VALIDATION_ERROR', message: 'One or more fields exceed the maximum length restriction' });
} else { } else {
log.db.error(err); log.db.error(err);
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' }); res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' });
@ -176,6 +180,10 @@ async function patch(req: Request, res: Response) {
// P2002 -> "Unique constraint failed on the {constraint}" // P2002 -> "Unique constraint failed on the {constraint}"
// https://www.prisma.io/docs/reference/api-reference/error-reference // https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(409).json({ status: 'ERROR', errorcode: 'EXISTING', message: 'Category already exists' }); res.status(409).json({ status: 'ERROR', errorcode: 'EXISTING', message: 'Category already exists' });
} else if (err.code == 'P2000') {
// P2000 -> "The provided value for the column is too long for the column's type. Column: {column_name}"
// https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(404).json({ status: 'ERROR', errorcode: 'VALIDATION_ERROR', message: 'One or more fields exceed the maximum length restriction' });
} else { } else {
log.db.error(err); log.db.error(err);
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' }); res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' });

View File

@ -183,6 +183,10 @@ function post(req: Request, res: Response) {
// https://www.prisma.io/docs/reference/api-reference/error-reference // https://www.prisma.io/docs/reference/api-reference/error-reference
// FIXME: Is this errormessage right? // FIXME: Is this errormessage right?
res.status(404).json({ status: 'ERROR', errorcode: 'NOT_EXISTING', message: 'Item does not exist' }); res.status(404).json({ status: 'ERROR', errorcode: 'NOT_EXISTING', message: 'Item does not exist' });
} else if (err.code == 'P2000') {
// P2000 -> "The provided value for the column is too long for the column's type. Column: {column_name}"
// https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(404).json({ status: 'ERROR', errorcode: 'VALIDATION_ERROR', message: 'One or more fields exceed the maximum length restriction' });
} else { } else {
log.db.error(err); log.db.error(err);
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' }); res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' });
@ -255,6 +259,10 @@ async function patch(req: Request, res: Response) {
// P2003 -> "Foreign key constraint failed on the field: {field_name}" // P2003 -> "Foreign key constraint failed on the field: {field_name}"
// https://www.prisma.io/docs/reference/api-reference/error-reference // https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(404).json({ status: 'ERROR', errorcode: 'NOT_EXISTING', message: 'Item does not exist' }); res.status(404).json({ status: 'ERROR', errorcode: 'NOT_EXISTING', message: 'Item does not exist' });
} else if (err.code == 'P2000') {
// P2000 -> "The provided value for the column is too long for the column's type. Column: {column_name}"
// https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(404).json({ status: 'ERROR', errorcode: 'VALIDATION_ERROR', message: 'One or more fields exceed the maximum length restriction' });
} else { } else {
log.db.error(err); log.db.error(err);
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' }); res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' });

View File

@ -113,6 +113,10 @@ function post(req: Request, res: Response) {
// https://www.prisma.io/docs/reference/api-reference/error-reference // https://www.prisma.io/docs/reference/api-reference/error-reference
// FIXME: Is this errormessage right? // FIXME: Is this errormessage right?
res.status(404).json({ status: 'ERROR', errorcode: 'NOT_EXISTING', message: 'storageUnitId does not exist' }); res.status(404).json({ status: 'ERROR', errorcode: 'NOT_EXISTING', message: 'storageUnitId does not exist' });
} else if (err.code == 'P2000') {
// P2000 -> "The provided value for the column is too long for the column's type. Column: {column_name}"
// https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(404).json({ status: 'ERROR', errorcode: 'VALIDATION_ERROR', message: 'One or more fields exceed the maximum length restriction' });
} else { } else {
log.db.error(err); log.db.error(err);
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' }); res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' });
@ -172,6 +176,10 @@ async function patch(req: Request, res: Response) {
// https://www.prisma.io/docs/reference/api-reference/error-reference // https://www.prisma.io/docs/reference/api-reference/error-reference
// FIXME: Is this errormessage right? // FIXME: Is this errormessage right?
res.status(404).json({ status: 'ERROR', errorcode: 'NOT_EXISTING', message: 'storageUnitId does not exist' }); res.status(404).json({ status: 'ERROR', errorcode: 'NOT_EXISTING', message: 'storageUnitId does not exist' });
} else if (err.code == 'P2000') {
// P2000 -> "The provided value for the column is too long for the column's type. Column: {column_name}"
// https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(404).json({ status: 'ERROR', errorcode: 'VALIDATION_ERROR', message: 'One or more fields exceed the maximum length restriction' });
} else { } else {
log.db.error(err); log.db.error(err);
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' }); res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' });

View File

@ -122,6 +122,10 @@ function post(req: Request, res: Response) {
// P2002 -> "Unique constraint failed on the {constraint}" // P2002 -> "Unique constraint failed on the {constraint}"
// https://www.prisma.io/docs/reference/api-reference/error-reference // https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(409).json({ status: 'ERROR', errorcode: 'EXISTING', message: 'storageUnit already exists' }); res.status(409).json({ status: 'ERROR', errorcode: 'EXISTING', message: 'storageUnit already exists' });
} else if (err.code == 'P2000') {
// P2000 -> "The provided value for the column is too long for the column's type. Column: {column_name}"
// https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(404).json({ status: 'ERROR', errorcode: 'VALIDATION_ERROR', message: 'One or more fields exceed the maximum length restriction' });
} else { } else {
log.db.error(err); log.db.error(err);
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' }); res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' });
@ -157,6 +161,10 @@ function post(req: Request, res: Response) {
// P2002 -> "Unique constraint failed on the {constraint}" // P2002 -> "Unique constraint failed on the {constraint}"
// https://www.prisma.io/docs/reference/api-reference/error-reference // https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(409).json({ status: 'ERROR', errorcode: 'EXISTING', message: 'storageUnit already exists' }); res.status(409).json({ status: 'ERROR', errorcode: 'EXISTING', message: 'storageUnit already exists' });
} else if (err.code == 'P2000') {
// P2000 -> "The provided value for the column is too long for the column's type. Column: {column_name}"
// https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(404).json({ status: 'ERROR', errorcode: 'VALIDATION_ERROR', message: 'One or more fields exceed the maximum length restriction' });
} else { } else {
log.db.error(err); log.db.error(err);
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' }); res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' });
@ -233,6 +241,10 @@ async function patch(req: Request, res: Response) {
// P2002 -> "Unique constraint failed on the {constraint}" // P2002 -> "Unique constraint failed on the {constraint}"
// https://www.prisma.io/docs/reference/api-reference/error-reference // https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(409).json({ status: 'ERROR', errorcode: 'EXISTING', message: 'storageUnit already exists' }); res.status(409).json({ status: 'ERROR', errorcode: 'EXISTING', message: 'storageUnit already exists' });
} else if (err.code == 'P2000') {
// P2000 -> "The provided value for the column is too long for the column's type. Column: {column_name}"
// https://www.prisma.io/docs/reference/api-reference/error-reference
res.status(404).json({ status: 'ERROR', errorcode: 'VALIDATION_ERROR', message: 'One or more fields exceed the maximum length restriction' });
} else { } else {
log.db.error(err); log.db.error(err);
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' }); res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' });