Skip to content

Commit

Permalink
fix: 예외 고도화 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
nuyh99 committed Aug 2, 2023
1 parent a4e8892 commit 6db2b02
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public enum BadRequestCode {
NOT_EMPTY_ESSAY_ANSWER_EXCEPTION(8013, "답변은 공백일 수 없습니다."),
ESSAY_ANSWER_NOT_VALID_USER(8014, "본인이 작성한 답변만 수정할 수 있습니다."),

ROADMAP_RECOMMENDED_POST_NOT_FOUND(8101, "해당 추천 포스트가 존재하지 않습니다."),

FILE_NAME_EMPTY_EXCEPTION(9001, "파일 이름이 존재하지 않습니다."),
UNSUPPORTED_FILE_EXTENSION_EXCEPTION(9002, "지원하지 않는 파일 확장자입니다."),
FILE_UPLOAD_FAIL_EXCEPTION(9003, "파일 업로드에 실패했습니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import wooteco.prolog.common.exception.BadRequestException;
import wooteco.prolog.roadmap.application.dto.RecommendedRequest;
import wooteco.prolog.roadmap.application.dto.RecommendedUpdateRequest;
import wooteco.prolog.roadmap.domain.Keyword;
import wooteco.prolog.roadmap.domain.RecommendedPost;
import wooteco.prolog.roadmap.domain.repository.KeywordRepository;
import wooteco.prolog.roadmap.domain.repository.RecommendedRepository;
import wooteco.prolog.roadmap.exception.KeywordNotFoundException;
import wooteco.prolog.roadmap.exception.RecommendedPostNotFoundException;

import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION;
import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_RECOMMENDED_POST_NOT_FOUND;

@Transactional(readOnly = true)
@Service
Expand All @@ -35,7 +37,7 @@ public Long create(final Long keywordId, final RecommendedRequest request) {

private Keyword findKeywordOrThrow(final Long keywordId) {
return keywordRepository.findById(keywordId)
.orElseThrow(KeywordNotFoundException::new);
.orElseThrow(() -> new BadRequestException(ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION));
}

@Transactional
Expand All @@ -47,7 +49,7 @@ public void update(final Long recommendedId, final RecommendedUpdateRequest requ

private RecommendedPost findPostOrThrow(final Long recommendedId) {
return recommendedRepository.findById(recommendedId)
.orElseThrow(RecommendedPostNotFoundException::new);
.orElseThrow(() -> new BadRequestException(ROADMAP_RECOMMENDED_POST_NOT_FOUND));
}

@Transactional
Expand Down

This file was deleted.

0 comments on commit 6db2b02

Please sign in to comment.