File: /var/www/api-storage/src/shared/utils/error-handler.ts
import { HttpException, HttpStatus } from '@nestjs/common';
import messages from './messages/messagest';
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
export function handleValidationError(error: any): HttpException {
const statusCode = Number(error?.status) || HttpStatus.INTERNAL_SERVER_ERROR;
return new HttpException(
{
status: statusCode,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
error: error,
message: messages.error.server,
timestamp: new Date().toISOString(),
},
statusCode,
);
}