-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(be): refactoring exception handling logic (#239)
refactor: refactoring exception handling logic
- Loading branch information
Showing
11 changed files
with
245 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,7 @@ | ||
import { HttpException, HttpStatus } from '@nestjs/common'; | ||
|
||
export class ResourceNotFoundException extends HttpException { | ||
constructor(resource: string) { | ||
super(`${resource}를 찾을 수 없습니다.`, HttpStatus.NOT_FOUND); | ||
} | ||
} | ||
|
||
export class ResourceConflictException extends HttpException { | ||
constructor(message: string) { | ||
super(message, HttpStatus.CONFLICT); | ||
} | ||
} | ||
|
||
export class DatabaseException extends HttpException { | ||
constructor(operation: string) { | ||
super(`데이터베이스 ${operation} 중 오류가 발생했습니다`, HttpStatus.INTERNAL_SERVER_ERROR); | ||
} | ||
|
||
static create(entity: string) { | ||
return new DatabaseException(`${entity} 생성`); | ||
} | ||
|
||
static read(entity: string) { | ||
return new DatabaseException(`${entity} 조회`); | ||
} | ||
|
||
static update(entity: string) { | ||
return new DatabaseException(`${entity} 수정`); | ||
} | ||
|
||
static delete(entity: string) { | ||
return new DatabaseException(`${entity} 삭제`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.