Browse Source

fix: avoid logging known db errors

pull/8388/head
mertmit 7 months ago
parent
commit
21073b32cc
  1. 5
      packages/nocodb/src/filters/global-exception/global-exception.filter.ts
  2. 2
      packages/nocodb/src/helpers/catchError.ts

5
packages/nocodb/src/filters/global-exception/global-exception.filter.ts

@ -39,10 +39,13 @@ export class GlobalExceptionFilter implements ExceptionFilter {
exception = new NcBaseErrorv2(NcErrorType.BAD_JSON);
}
const dbError = extractDBError(exception);
// skip unnecessary error logging
if (
process.env.NC_ENABLE_ALL_API_ERROR_LOGGING === 'true' ||
!(
dbError ||
exception instanceof BadRequest ||
exception instanceof AjvError ||
exception instanceof Unauthorized ||
@ -97,8 +100,6 @@ export class GlobalExceptionFilter implements ExceptionFilter {
return response.status(404).json({ msg: exception.message });
}
const dbError = extractDBError(exception);
if (dbError) {
return response.status(400).json(dbError);
}

2
packages/nocodb/src/helpers/catchError.ts

@ -3,7 +3,7 @@ import { Logger } from '@nestjs/common';
import type { ErrorObject } from 'ajv';
import { defaultLimitConfig } from '~/helpers/extractLimitAndOffset';
const dbErrorLogger = new Logger('DBError');
const dbErrorLogger = new Logger('MissingDBError');
export enum DBError {
TABLE_EXIST = 'TABLE_EXIST',

Loading…
Cancel
Save