From 44e82567ed39537370954249f867e19b09014697 Mon Sep 17 00:00:00 2001 From: Phill Pover Date: Mon, 7 Apr 2025 11:01:07 +0100 Subject: [PATCH] Pushing errors back to frontend --- backend/src/main.ts | 14 ++------------ frontend/src/app/album/page.tsx | 1 - 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/backend/src/main.ts b/backend/src/main.ts index 58f0758..761f105 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -1,9 +1,5 @@ import { NestFactory } from '@nestjs/core'; -import { - UnprocessableEntityException, - ValidationError, - ValidationPipe, -} from '@nestjs/common'; +import { UnprocessableEntityException, ValidationError, ValidationPipe } from '@nestjs/common'; import { AppModule } from './app.module'; async function bootstrap() { @@ -26,8 +22,7 @@ async function bootstrap() { validationErrors: ValidationError[], parentProperty = '', ): Array<{ property: string; errors: string[] }> => { - const errors: Array<{ property: string; errors: string[] }> = []; - + const errors : Array<{ property: string; errors: string[] }> = []; const getValidationErrorsRecursively = ( validationErrors: ValidationError[], parentProperty = '', @@ -43,20 +38,15 @@ async function bootstrap() { errors: Object.values(error.constraints), }); } - if (error.children?.length) { getValidationErrorsRecursively(error.children, propertyPath); } } }; - getValidationErrorsRecursively(validationErrors, parentProperty); - return errors; }; - const errors = getPrettyClassValidatorErrors(validationErrors); - return new UnprocessableEntityException({ message: 'validation error', errors: errors, diff --git a/frontend/src/app/album/page.tsx b/frontend/src/app/album/page.tsx index e9d8562..5f9b439 100644 --- a/frontend/src/app/album/page.tsx +++ b/frontend/src/app/album/page.tsx @@ -111,7 +111,6 @@ export default function Page() { setSnackbarMessage(message); setSnackbarSuccess(severity); handleOpenSnackbar(); - } if (!albums) return
Loading...