diff --git a/src/common/interceptors/transaction.interceptor.ts b/src/common/interceptors/transaction.interceptor.ts index 14566c2..234d141 100644 --- a/src/common/interceptors/transaction.interceptor.ts +++ b/src/common/interceptors/transaction.interceptor.ts @@ -24,14 +24,17 @@ export class TransactionInterceptor implements NestInterceptor { return next.handle().pipe( catchError(async (e) => { - console.log('check err ', e.message); await queryRunner.rollbackTransaction(); await queryRunner.release(); + const errorMessage = e.response.message[0] + ? e.response.message[0] + : e.message; + if (e instanceof HttpException) { - throw new HttpException(e.message, e.getStatus()); + throw new HttpException(errorMessage, e.getStatus()); } else { - throw new InternalServerErrorException(e.message); + throw new InternalServerErrorException(errorMessage); } }), tap(async () => { diff --git a/src/users/dtos/edit-profile.dto.ts b/src/users/dtos/edit-profile.dto.ts index 4367c29..9605857 100644 --- a/src/users/dtos/edit-profile.dto.ts +++ b/src/users/dtos/edit-profile.dto.ts @@ -1,5 +1,5 @@ import { ApiProperty, PartialType, PickType } from '@nestjs/swagger'; -import { IsString } from 'class-validator'; +import { IsOptional, IsString } from 'class-validator'; import { CoreOutput } from '../../common/dtos/output.dto'; import { User } from '../entities/user.entity'; @@ -10,5 +10,6 @@ export class EditProfileInput extends PartialType( ) { @ApiProperty({ description: '기존 비밀번호', required: false }) @IsString() + @IsOptional() oldPassword?: string; } diff --git a/src/users/entities/user.entity.ts b/src/users/entities/user.entity.ts index f5ab814..da04aa7 100644 --- a/src/users/entities/user.entity.ts +++ b/src/users/entities/user.entity.ts @@ -40,7 +40,7 @@ export class User extends CoreEntity { @ApiProperty({ example: 'passw0rd', description: 'User Password' }) @Column({ select: false }) - @IsString() + @IsString({ message: 'Password is required' }) @Matches(/^(?=.*\d)[A-Za-z\d@$!%*?&]{8,}$/, { message: 'Password must be at least 8 characters long, contain 1 number', })