Browse Source

refactor: error code corrections

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5747/head
Pranav C 2 years ago
parent
commit
d2af09133d
  1. 12
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 6
      packages/nocodb/src/services/data-table.service.ts

12
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -3699,7 +3699,7 @@ class BaseModelSqlv2 {
!childRows.find((r) => r[parentColumn.column_name] === id),
);
NcError.notFound(
NcError.unprocessableEntity(
`Child record with id ${missingIds.join(', ')} not found`,
);
}
@ -3777,7 +3777,7 @@ class BaseModelSqlv2 {
!childRows.find((r) => r[parentColumn.column_name] === id),
);
NcError.notFound(
NcError.unprocessableEntity(
`Child record with id ${missingIds.join(', ')} not found`,
);
}
@ -3809,7 +3809,7 @@ class BaseModelSqlv2 {
const childRow = await childRowsQb;
if (!childRow) {
NcError.notFound(`Child record with id ${childIds[0]} not found`);
NcError.unprocessableEntity(`Child record with id ${childIds[0]} not found`);
}
}
@ -3899,7 +3899,7 @@ class BaseModelSqlv2 {
!childRows.find((r) => r[parentColumn.column_name] === id),
);
NcError.notFound(
NcError.unprocessableEntity(
`Child record with id ${missingIds.join(', ')} not found`,
);
}
@ -3939,7 +3939,7 @@ class BaseModelSqlv2 {
!childRows.find((r) => r[parentColumn.column_name] === id),
);
NcError.notFound(
NcError.unprocessableEntity(
`Child record with id ${missingIds.join(', ')} not found`,
);
}
@ -3969,7 +3969,7 @@ class BaseModelSqlv2 {
const childRow = await childRowsQb;
if (!childRow) {
NcError.notFound(`Child record with id ${childIds[0]} not found`);
NcError.unprocessableEntity(`Child record with id ${childIds[0]} not found`);
}
}

6
packages/nocodb/src/services/data-table.service.ts

@ -409,14 +409,14 @@ export class DataTableService {
const map = new Map<string, boolean>();
for (const rowId of rowIds) {
if (rowId === undefined || rowId === null)
NcError.badRequest('Invalid row id ' + rowId);
NcError.unprocessableEntity('Invalid row id ' + rowId);
if (map.has(rowId)) {
NcError.badRequest('Duplicate row with id ' + rowId);
NcError.unprocessableEntity('Duplicate row with id ' + rowId);
}
map.set(rowId, true);
}
} else if (rowIds === undefined || rowIds === null) {
NcError.badRequest('Invalid row id ' + rowIds);
NcError.unprocessableEntity('Invalid row id ' + rowIds);
}
}
}

Loading…
Cancel
Save