Skip to content

Commit

Permalink
♻️ [STMT-171] 메시지를 예외 클래스안에서 관리하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
zxcv9203 committed Apr 13, 2024
1 parent b36bed1 commit 5b0e7e9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ public class StudyMemberValidationService implements StudyMemberValidationUseCas
@Override
public void checkStudyJoinMember(Long studyId, Long memberId) {
if (studyMemberValidationPort.isNotStudyJoinMember(studyId, memberId)) {
throw new StudyMemberNotJoinedException("스터디에 가입된 멤버가 아닙니다. 전달받은 studyId=" + studyId + ", memberId=" + memberId);
throw new StudyMemberNotJoinedException(studyId, memberId);
}
}

@Override
public void checkAlreadyStudyJoinMember(Long studyId, Long memberId) {
if (studyMemberValidationPort.isAlreadyStudyJoinMember(studyId, memberId)) {
throw new AlreadyStudyJoinMemberException("스터디에 이미 가입한 멤버입니다. 전달받은 studyId=" + studyId + ", memberId=" + memberId);
throw new AlreadyStudyJoinMemberException(studyId, memberId);
}
}

@Override
public void checkAdmin(Long studyId, Long adminId) {
if (studyMemberValidationPort.isNotAdmin(studyId, adminId)) {
throw new NotStudyAdminException("스터디 관리자가 아닙니다. 전달받은 studyId=" + studyId + ", adminId=" + adminId);
throw new NotStudyAdminException(studyId, adminId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import com.stumeet.server.common.exception.model.InvalidStateException;
import com.stumeet.server.common.response.ErrorCode;

import java.text.MessageFormat;

public class AlreadyStudyJoinMemberException extends InvalidStateException {
public AlreadyStudyJoinMemberException(String message) {
super(message, ErrorCode.ALREADY_STUDY_JOIN_MEMBER_EXCEPTION);
private static final String MESSAGE = "이미 스터디에 가입한 멤버입니다. studyId={0}, memberId={1}";
public AlreadyStudyJoinMemberException(Long studyId, Long memberId) {
super(MessageFormat.format(MESSAGE, studyId, memberId), ErrorCode.ALREADY_STUDY_JOIN_MEMBER_EXCEPTION);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
import com.stumeet.server.common.exception.model.InvalidStateException;
import com.stumeet.server.common.response.ErrorCode;

import java.text.MessageFormat;

public class NotStudyAdminException extends InvalidStateException {
public NotStudyAdminException(String message) {
super(message, ErrorCode.NOT_STUDY_ADMIN_EXCEPTION);

private static final String MESSAGE = "스터디 관리자가 아닙니다. 전달받은 studyId={0}, memberId={1}";
public NotStudyAdminException(Long studyId, Long memberId) {
super(MessageFormat.format(MESSAGE, studyId, memberId), ErrorCode.NOT_STUDY_ADMIN_EXCEPTION);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import com.stumeet.server.common.exception.model.InvalidStateException;
import com.stumeet.server.common.response.ErrorCode;

public class StudyMemberNotJoinedException extends InvalidStateException {
import java.text.MessageFormat;

public StudyMemberNotJoinedException(String message) {
super(message, ErrorCode.STUDY_MEMBER_NOT_JOINED_EXCEPTION);
public class StudyMemberNotJoinedException extends InvalidStateException {
private static final String MESSAGE = "스터디에 가입된 멤버가 아닙니다. 전달받은 studyId={0}, memberId={1}";
public StudyMemberNotJoinedException(Long studyId, Long memberId) {
super(MessageFormat.format(MESSAGE, studyId, memberId), ErrorCode.STUDY_MEMBER_NOT_JOINED_EXCEPTION);
}
}

0 comments on commit 5b0e7e9

Please sign in to comment.