-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
## Docs | ||
|
||
- [docker-compose](docs/docker-compose.md) | ||
- [kubernetes](docs/kubernetes.md) | ||
- [package-structure](docs/package-structure.md) | ||
- [Package 구조](docs/package-structure.md) | ||
- [Service layer 개발 방법](docs/service.md) | ||
- [Docker Compose 사용 방법](docs/docker-compose.md) | ||
- [Kubernetes 사용 방법](docs/kubernetes.md) |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## Exception Handling | ||
|
||
> Service layer의 exception handling은 [`GlobalExceptionHandler`](src/main/java/com/server/global/error/handler/GlobalExceptionHandler.java)를 통해 관리 | ||
```java | ||
@RestControllerAdvice | ||
public class GlobalExceptionHandler { | ||
|
||
@ExceptionHandler(AuthException.class) | ||
public ResponseEntity<ApiResponseDto<Object>> handleFriendException(AuthException e) { | ||
return ResponseEntity.status(e.getStatus()).body(ApiResponseDto.error(e.getStatus(), e.getMessage())); | ||
} | ||
|
||
@ExceptionHandler(BusinessException.class) | ||
public ResponseEntity<ApiResponseDto<Object>> handleFriendException(BusinessException e) { | ||
return ResponseEntity.status(e.getStatus()).body(ApiResponseDto.error(e.getStatus(), e.getMessage())); | ||
} | ||
|
||
} | ||
``` | ||
|
||
> [`ErrorCode`](src/main/java/com/server/global/error/code) 및 [`Exception`](src/main/java/com/server/global/error/exception) 정의 후 아래 예시와 같이 service layer에서 예외 생성 | ||
```java | ||
throw new AuthException(AuthErrorCode.OAUTH_PROCESS_ERROR); | ||
throw new BusinessException(FriendErrorCode.RECEIPT_ALREADY_EXISTS); | ||
``` |