Skip to content

Commit d6cd898

Browse files
committed
[hotfix] 문항 못찾을 때 번호 로깅
1 parent 375823e commit d6cd898

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/main/java/com/moplus/moplus_server/domain/problem/repository/ProblemRepository.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
import com.moplus.moplus_server.global.error.exception.ErrorCode;
66
import com.moplus.moplus_server.global.error.exception.NotFoundException;
77
import java.util.Optional;
8+
import org.slf4j.Logger;
9+
import org.slf4j.LoggerFactory;
810
import org.springframework.data.jpa.repository.JpaRepository;
911
import org.springframework.data.jpa.repository.Query;
1012
import org.springframework.data.repository.query.Param;
1113

1214
public interface ProblemRepository extends JpaRepository<Problem, Long> {
1315

16+
Logger log = LoggerFactory.getLogger(ProblemRepository.class);
17+
1418
boolean existsByProblemCustomId(ProblemCustomId problemCustomId);
1519

1620
default void existsByIdElseThrow(Long id) {
@@ -25,11 +29,18 @@ default void existsByIdElseThrow(Long id) {
2529
Optional<Problem> findByIdWithFetchJoin(@Param("id") Long id);
2630

2731
default Problem findByIdElseThrow(Long id) {
32+
2833
return findById(id).orElseThrow(
29-
() -> new NotFoundException(ErrorCode.PROBLEM_NOT_FOUND, id + "번 문제가 존재하지 않습니다."));
34+
() -> {
35+
log.atError().log("id " + id + "번 문항이 존재하지 않습니다.");
36+
throw new NotFoundException(ErrorCode.PROBLEM_NOT_FOUND);
37+
});
3038
}
3139

3240
default Problem findByIdWithFetchJoinElseThrow(Long id) {
33-
return findByIdWithFetchJoin(id).orElseThrow(() -> new NotFoundException(ErrorCode.PROBLEM_NOT_FOUND));
41+
return findByIdWithFetchJoin(id).orElseThrow(() -> {
42+
log.atError().log("id " + id + "번 문항이 존재하지 않습니다.");
43+
throw new NotFoundException(ErrorCode.PROBLEM_NOT_FOUND);
44+
});
3445
}
3546
}

0 commit comments

Comments
 (0)