Service layer의 exception handling은
GlobalExceptionHandler
를 통해 관리
@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()));
}
}
throw new AuthException(AuthErrorCode.OAUTH_PROCESS_ERROR);
throw new BusinessException(FriendErrorCode.RECEIPT_ALREADY_EXISTS);