Skip to content

Commit

Permalink
refactor: getUser 에서 유저가 발견되지 않으면 오류 발생 (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
son-daehyeon authored Aug 30, 2024
1 parent 532dfa7 commit 3af39af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.github.winkathon.lingo.domain.user.exception;

import org.springframework.http.HttpStatus;

import com.github.winkathon.lingo.common.api.exception.ApiException;

public class UserNotFoundException extends ApiException {

public UserNotFoundException() {

super(HttpStatus.NOT_FOUND, "유저를 찾을 수 없습니다.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.github.winkathon.lingo.domain.user.dto.request.ChangePasswordRequest;
import com.github.winkathon.lingo.domain.user.dto.response.UserListResponse;
import com.github.winkathon.lingo.domain.user.dto.response.UserResponse;
import com.github.winkathon.lingo.domain.user.exception.UserNotFoundException;
import com.github.winkathon.lingo.domain.user.repository.UserRepository;
import com.github.winkathon.lingo.domain.user.schema.User;

Expand Down Expand Up @@ -45,7 +46,7 @@ public UserResponse getUser(String userId) {

return user1;
})
.orElse(null);
.orElseThrow(UserNotFoundException::new);

return UserResponse.builder()
.user(user)
Expand Down

0 comments on commit 3af39af

Please sign in to comment.