reduce code duplication

This commit is contained in:
hannathkadher
2025-02-04 15:03:47 +04:00
parent 33d7d60755
commit b04d013d95

View File

@ -58,7 +58,7 @@ export class SubSpaceService {
return await queryRunner.manager.save(subspaces); return await queryRunner.manager.save(subspaces);
} catch (error) { } catch (error) {
throw new HttpException( throw new HttpException(
'An unexpected error occurred while creating subspaces.', `An unexpected error occurred while creating subspaces. ${error}`,
HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR,
); );
} }
@ -98,9 +98,8 @@ export class SubSpaceService {
otherTags?: CreateTagDto[], otherTags?: CreateTagDto[],
): Promise<SubspaceEntity[]> { ): Promise<SubspaceEntity[]> {
try { try {
await this.validateName( this.checkForDuplicateNames(
addSubspaceDtos.map((dto) => dto.subspaceName), addSubspaceDtos.map(({ subspaceName }) => subspaceName),
space,
); );
const subspaceData = addSubspaceDtos.map((dto) => ({ const subspaceData = addSubspaceDtos.map((dto) => ({