implemented AFLOW-27
This commit is contained in:
parent
ea80b4bf2b
commit
421085a8d5
@ -122,6 +122,10 @@ function post(req: Request, res: Response) {
|
||||
// P2002 -> "Unique constraint failed on the {constraint}"
|
||||
// https://www.prisma.io/docs/reference/api-reference/error-reference
|
||||
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 {
|
||||
log.db.error(err);
|
||||
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}"
|
||||
// https://www.prisma.io/docs/reference/api-reference/error-reference
|
||||
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 {
|
||||
log.db.error(err);
|
||||
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' });
|
||||
|
@ -183,6 +183,10 @@ function post(req: Request, res: Response) {
|
||||
// https://www.prisma.io/docs/reference/api-reference/error-reference
|
||||
// FIXME: Is this errormessage right?
|
||||
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 {
|
||||
log.db.error(err);
|
||||
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}"
|
||||
// https://www.prisma.io/docs/reference/api-reference/error-reference
|
||||
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 {
|
||||
log.db.error(err);
|
||||
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' });
|
||||
|
@ -113,6 +113,10 @@ function post(req: Request, res: Response) {
|
||||
// https://www.prisma.io/docs/reference/api-reference/error-reference
|
||||
// FIXME: Is this errormessage right?
|
||||
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 {
|
||||
log.db.error(err);
|
||||
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
|
||||
// FIXME: Is this errormessage right?
|
||||
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 {
|
||||
log.db.error(err);
|
||||
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' });
|
||||
|
@ -122,6 +122,10 @@ function post(req: Request, res: Response) {
|
||||
// P2002 -> "Unique constraint failed on the {constraint}"
|
||||
// https://www.prisma.io/docs/reference/api-reference/error-reference
|
||||
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 {
|
||||
log.db.error(err);
|
||||
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}"
|
||||
// https://www.prisma.io/docs/reference/api-reference/error-reference
|
||||
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 {
|
||||
log.db.error(err);
|
||||
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}"
|
||||
// https://www.prisma.io/docs/reference/api-reference/error-reference
|
||||
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 {
|
||||
log.db.error(err);
|
||||
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', error: err, message: 'An error occurred during the database operation' });
|
||||
|
Loading…
Reference in New Issue
Block a user