Browse Source

fix: if NcError handle throw it

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/6770/head
Pranav C 1 year ago
parent
commit
c9fc3f35a3
  1. 24
      packages/nocodb/src/helpers/catchError.ts
  2. 3
      packages/nocodb/src/services/datas.service.ts

24
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;

3
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',

Loading…
Cancel
Save