diff --git a/packages/nocodb/src/helpers/catchError.ts b/packages/nocodb/src/helpers/catchError.ts index 6182cd93fc..289727f7d9 100644 --- a/packages/nocodb/src/helpers/catchError.ts +++ b/packages/nocodb/src/helpers/catchError.ts @@ -436,23 +436,29 @@ export default function ( }; } -export class BadRequest extends Error {} +export class NcBaseError extends Error { + constructor(message: string) { + super(message); + } +} + +export class BadRequest extends NcBaseError {} -export class NotAllowed extends Error {} +export class NotAllowed extends NcBaseError {} -export class Unauthorized extends Error {} +export class Unauthorized extends NcBaseError {} -export class Forbidden extends Error {} +export class Forbidden extends NcBaseError {} -export class NotFound extends Error {} +export class NotFound extends NcBaseError {} -export class InternalServerError extends Error {} +export class InternalServerError extends NcBaseError {} -export class NotImplemented extends Error {} +export class NotImplemented extends NcBaseError {} -export class UnprocessableEntity extends Error {} +export class UnprocessableEntity extends NcBaseError {} -export class AjvError extends Error { +export class AjvError extends NcBaseError { constructor(param: { message: string; errors: ErrorObject[] }) { super(param.message); this.errors = param.errors; diff --git a/packages/nocodb/src/services/datas.service.ts b/packages/nocodb/src/services/datas.service.ts index 64d6f4f88f..fbbc4ee5db 100644 --- a/packages/nocodb/src/services/datas.service.ts +++ b/packages/nocodb/src/services/datas.service.ts @@ -7,7 +7,7 @@ import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2'; import type { PathParams } from '~/modules/datas/helpers'; import { getDbRows, getViewAndModelByAliasOrId } from '~/modules/datas/helpers'; import { Base, Column, Model, Source, View } from '~/models'; -import { NcError } from '~/helpers/catchError'; +import { NcBaseError, NcError } from '~/helpers/catchError'; import getAst from '~/helpers/getAst'; import { PagedResponseImpl } from '~/helpers/PagedResponse'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; @@ -179,6 +179,7 @@ export class DatasService { listArgs, ); } catch (e) { + if (e instanceof NcBaseError) throw e; this.logger.log(e); NcError.internalServerError( 'Please check server log for more details',