forked from Shared/esg
some error handler + error validation + realEstate bug fixed for hamta end moallem
This commit is contained in:
10
src/main.ts
10
src/main.ts
@@ -1,5 +1,5 @@
|
||||
import './telemetry';
|
||||
import { Logger, ValidationPipe } from '@nestjs/common';
|
||||
import { BadRequestException, Logger, ValidationPipe } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
@@ -7,6 +7,7 @@ import { NextFunction, Request, Response } from 'express';
|
||||
import { AppModule } from './app.module';
|
||||
import { API_KEY_HEADER } from './common/constants/app.constants';
|
||||
import { OpenTelemetryNestLogger } from './otel-nest-logger';
|
||||
import { buildValidationErrorResponse } from './common/helpers/validation-error.helper';
|
||||
import {
|
||||
recordHttpRequestEnd,
|
||||
recordHttpRequestStart,
|
||||
@@ -46,6 +47,13 @@ async function bootstrap(): Promise<void> {
|
||||
forbidNonWhitelisted: true,
|
||||
transform: true,
|
||||
transformOptions: { enableImplicitConversion: true },
|
||||
exceptionFactory: (errors) => {
|
||||
const { normalizedError } = buildValidationErrorResponse(errors);
|
||||
return new BadRequestException({
|
||||
message: normalizedError.message,
|
||||
error: normalizedError,
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user