Browse Source

Merge pull request #8388 from nocodb/nc-fix/suppress-known-db-errors

fix: avoid logging known db errors
pull/8391/head
Pranav C 6 months ago committed by GitHub
parent
commit
e65c1190bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  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