From 91d0c8de74d410c2703f2b2eafadb1e0bee544e1 Mon Sep 17 00:00:00 2001 From: hou27 Date: Fri, 10 Nov 2023 00:39:15 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20transaction=20interceptor=20err=20m?= =?UTF-8?q?essage=20=EC=BD=94=EB=93=9C=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/interceptors/transaction.interceptor.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 () => { From 95b7f19b52557eb1c49cf256a606d8ac4cf1c61b Mon Sep 17 00:00:00 2001 From: hou27 Date: Fri, 10 Nov 2023 00:42:13 +0900 Subject: [PATCH 2/2] =?UTF-8?q?hotfix:=20oldPassword=EA=B0=80=20=EC=97=86?= =?UTF-8?q?=EC=96=B4=EB=8F=84=20=ED=86=B5=EA=B3=BC=EB=90=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=8D=B0=EC=BD=94=EB=A0=88=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=20#216?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/users/dtos/edit-profile.dto.ts | 3 ++- src/users/entities/user.entity.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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', })