Pushing errors back to frontend
All checks were successful
Music Collection CI Workflow / test (./backend) (push) Successful in 35s
Music Collection CI Workflow / test (./frontend) (push) Successful in 39s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/music-collection-backend, ./backend) (push) Successful in 52s
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Successful in 1m51s
Music Collection CI Workflow / deploy (push) Successful in 24s

This commit is contained in:
Phill Pover 2025-04-07 11:01:07 +01:00
parent 6a2c451105
commit 44e82567ed
2 changed files with 2 additions and 13 deletions

View File

@ -1,9 +1,5 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { import { UnprocessableEntityException, ValidationError, ValidationPipe } from '@nestjs/common';
UnprocessableEntityException,
ValidationError,
ValidationPipe,
} from '@nestjs/common';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
async function bootstrap() { async function bootstrap() {
@ -26,8 +22,7 @@ async function bootstrap() {
validationErrors: ValidationError[], validationErrors: ValidationError[],
parentProperty = '', parentProperty = '',
): Array<{ property: string; errors: string[] }> => { ): Array<{ property: string; errors: string[] }> => {
const errors: Array<{ property: string; errors: string[] }> = []; const errors : Array<{ property: string; errors: string[] }> = [];
const getValidationErrorsRecursively = ( const getValidationErrorsRecursively = (
validationErrors: ValidationError[], validationErrors: ValidationError[],
parentProperty = '', parentProperty = '',
@ -43,20 +38,15 @@ async function bootstrap() {
errors: Object.values(error.constraints), errors: Object.values(error.constraints),
}); });
} }
if (error.children?.length) { if (error.children?.length) {
getValidationErrorsRecursively(error.children, propertyPath); getValidationErrorsRecursively(error.children, propertyPath);
} }
} }
}; };
getValidationErrorsRecursively(validationErrors, parentProperty); getValidationErrorsRecursively(validationErrors, parentProperty);
return errors; return errors;
}; };
const errors = getPrettyClassValidatorErrors(validationErrors); const errors = getPrettyClassValidatorErrors(validationErrors);
return new UnprocessableEntityException({ return new UnprocessableEntityException({
message: 'validation error', message: 'validation error',
errors: errors, errors: errors,

View File

@ -111,7 +111,6 @@ export default function Page() {
setSnackbarMessage(message); setSnackbarMessage(message);
setSnackbarSuccess(severity); setSnackbarSuccess(severity);
handleOpenSnackbar(); handleOpenSnackbar();
} }
if (!albums) return <div>Loading...</div> if (!albums) return <div>Loading...</div>