Skip to content

Commit 0d4101b

Browse files
fix: 역할 등록 중복 에러 구체화
1 parent 75fa96c commit 0d4101b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { BadRequestException } from '@nestjs/common';
2+
3+
export class UserAlreadyInWorkspaceException extends BadRequestException {
4+
constructor() {
5+
super('사용자가 이미 워크스페이스에 등록되어 있습니다.');
6+
}
7+
}

apps/backend/src/workspace/workspace.service.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { WorkspaceNotFoundException } from '../exception/workspace.exception';
1010
import { NotWorkspaceOwnerException } from '../exception/workspace-auth.exception';
1111
import { TokenService } from '../auth/token/token.service';
1212
import { ForbiddenAccessException } from '../exception/access.exception';
13+
import { UserAlreadyInWorkspaceException } from '../exception/role-duplicate.exception';
1314

1415
enum MainWorkspace {
1516
OWNER_SNOWFLAKEID = 'admin',
@@ -38,7 +39,6 @@ export class WorkspaceService {
3839
}
3940
}
4041

41-
4242
async createWorkspace(
4343
userId: number,
4444
dto: CreateWorkspaceDto,
@@ -154,9 +154,8 @@ export class WorkspaceService {
154154
});
155155

156156
// 이미 워크스페이스에 등록된 경우
157-
// TODO: 워크스페이스 관련 에러 구현
158157
if (existingRole) {
159-
throw new Error('이미 워크스페이스에 가입된 사용자입니다.');
158+
throw new UserAlreadyInWorkspaceException();
160159
}
161160

162161
// 새로운 역할 생성
@@ -205,7 +204,7 @@ export class WorkspaceService {
205204
// 권한이 없으면 예외 발생
206205
throw new ForbiddenAccessException();
207206
}
208-
207+
209208
// 가장 처음에 모두가 접속할 수 있는 main workspace를 생성한다.
210209
async initializeMainWorkspace() {
211210
let findOwner = await this.userRepository.findOneBy({

0 commit comments

Comments
 (0)