Skip to content

Commit 5618a93

Browse files
committed
♻️ refactor: schedule 도메인 예외 처리 리팩터링
전역 예외 처리에 맞게 schedule 도메인의 예외 처리 로직을 리팩터링 주요 변경 사항: - ScheduleErrorCode: ErrorCode 인터페이스를 구현하도록 수정 - schedule 예외 클래스: 모든 커스텀 예외가 CustomException을 상속하도록 변경 - ScheduleExceptionAdvice: ApiCustomExceptionAdvice로 역할이 통합됨에 따라 삭제
1 parent eab41a3 commit 5618a93

File tree

9 files changed

+30
-164
lines changed

9 files changed

+30
-164
lines changed
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.schedule;
22

3+
import com.grepp.spring.infra.error.exceptions.CustomException;
34
import com.grepp.spring.infra.response.ScheduleErrorCode;
45
import lombok.extern.slf4j.Slf4j;
56

67
@Slf4j
7-
public class EventNotActivatedException extends RuntimeException {
8-
9-
private final ScheduleErrorCode code;
8+
public class EventNotActivatedException extends CustomException {
109

1110
public EventNotActivatedException(ScheduleErrorCode code) {
12-
this.code = code;
11+
super(code);
1312
}
1413

1514
public EventNotActivatedException(ScheduleErrorCode code, Exception e) {
16-
this.code = code;
17-
log.error(e.getMessage(), e);
18-
}
19-
20-
public ScheduleErrorCode code() {
21-
return code;
15+
super(code, e);
2216
}
2317

2418
}
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.schedule;
22

3+
import com.grepp.spring.infra.error.exceptions.CustomException;
34
import com.grepp.spring.infra.response.ScheduleErrorCode;
45
import lombok.extern.slf4j.Slf4j;
56

67
@Slf4j
7-
public class LocationNotFoundException extends RuntimeException {
8-
9-
private final ScheduleErrorCode code;
8+
public class LocationNotFoundException extends CustomException {
109

1110
public LocationNotFoundException(ScheduleErrorCode code) {
12-
this.code = code;
11+
super(code);
1312
}
1413

1514
public LocationNotFoundException(ScheduleErrorCode code, Exception e) {
16-
this.code = code;
17-
log.error(e.getMessage(), e);
18-
}
19-
20-
public ScheduleErrorCode code() {
21-
return code;
15+
super(code, e);
2216
}
2317

2418
}
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.schedule;
22

3+
import com.grepp.spring.infra.error.exceptions.CustomException;
34
import com.grepp.spring.infra.response.ScheduleErrorCode;
45
import lombok.extern.slf4j.Slf4j;
56

67
@Slf4j
7-
public class NotScheduleMasterException extends RuntimeException{
8-
private final ScheduleErrorCode code;
8+
public class NotScheduleMasterException extends CustomException {
99

1010
public NotScheduleMasterException(ScheduleErrorCode code) {
11-
this.code = code;
11+
super(code);
1212
}
1313

1414
public NotScheduleMasterException(ScheduleErrorCode code, Exception e) {
15-
this.code = code;
16-
log.error(e.getMessage(), e);
15+
super(code, e);
1716
}
1817

19-
public ScheduleErrorCode code() {
20-
return code;
21-
}
2218
}
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.schedule;
22

3+
import com.grepp.spring.infra.error.exceptions.CustomException;
34
import com.grepp.spring.infra.response.ScheduleErrorCode;
45
import lombok.extern.slf4j.Slf4j;
56

67
@Slf4j
7-
public class NotScheduleMemberException extends RuntimeException {
8-
private final ScheduleErrorCode code;
8+
public class NotScheduleMemberException extends CustomException {
99

1010
public NotScheduleMemberException(ScheduleErrorCode code) {
11-
this.code = code;
11+
super(code);
1212
}
1313

1414
public NotScheduleMemberException(ScheduleErrorCode code, Exception e) {
15-
this.code = code;
16-
log.error(e.getMessage(), e);
15+
super(code, e);
1716
}
1817

19-
public ScheduleErrorCode code() {
20-
return code;
21-
}
2218
}
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.schedule;
22

3+
import com.grepp.spring.infra.error.exceptions.CustomException;
34
import com.grepp.spring.infra.response.ScheduleErrorCode;
45
import lombok.extern.slf4j.Slf4j;
56

67
@Slf4j
7-
public class ScheduleMemberNotFoundException extends RuntimeException {
8-
private final ScheduleErrorCode code;
8+
public class ScheduleMemberNotFoundException extends CustomException {
99

1010
public ScheduleMemberNotFoundException(ScheduleErrorCode code) {
11-
this.code = code;
11+
super(code);
1212
}
1313

1414
public ScheduleMemberNotFoundException(ScheduleErrorCode code, Exception e) {
15-
this.code = code;
16-
log.error(e.getMessage(), e);
15+
super(code, e);
1716
}
1817

19-
public ScheduleErrorCode code() {
20-
return code;
21-
}
2218
}
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.schedule;
22

3+
import com.grepp.spring.infra.error.exceptions.CustomException;
34
import com.grepp.spring.infra.response.ScheduleErrorCode;
45
import lombok.extern.slf4j.Slf4j;
56

67
@Slf4j
7-
public class VoteAlreadyProgressException extends RuntimeException {
8-
private final ScheduleErrorCode code;
8+
public class VoteAlreadyProgressException extends CustomException {
99

1010
public VoteAlreadyProgressException(ScheduleErrorCode code) {
11-
this.code = code;
11+
super(code);
1212
}
1313

1414
public VoteAlreadyProgressException(ScheduleErrorCode code, Exception e) {
15-
this.code = code;
16-
log.error(e.getMessage(), e);
15+
super(code, e);
1716
}
1817

19-
public ScheduleErrorCode code() {
20-
return code;
21-
}
2218
}
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.schedule;
22

3+
import com.grepp.spring.infra.error.exceptions.CustomException;
34
import com.grepp.spring.infra.response.ScheduleErrorCode;
45
import lombok.extern.slf4j.Slf4j;
56

67
@Slf4j
7-
public class WorkSpaceNotFoundException extends RuntimeException {
8-
private final ScheduleErrorCode code;
8+
public class WorkSpaceNotFoundException extends CustomException {
99

1010
public WorkSpaceNotFoundException(ScheduleErrorCode code) {
11-
this.code = code;
11+
super(code);
1212
}
1313

1414
public WorkSpaceNotFoundException(ScheduleErrorCode code, Exception e) {
15-
this.code = code;
16-
log.error(e.getMessage(), e);
15+
super(code, e);
1716
}
1817

19-
public ScheduleErrorCode code() {
20-
return code;
21-
}
2218
}

src/main/java/com/grepp/spring/infra/error/scheduleAdvuce/ScheduleExceptionAdvice.java

Lines changed: 0 additions & 103 deletions
This file was deleted.

src/main/java/com/grepp/spring/infra/response/ScheduleErrorCode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package com.grepp.spring.infra.response;
22

3+
import com.grepp.spring.infra.response.error.ErrorCode;
34
import org.springframework.http.HttpStatus;
45

5-
public enum ScheduleErrorCode {
6+
public enum ScheduleErrorCode implements ErrorCode {
67
NOT_SCHEDULE_MASTER("404", HttpStatus.NOT_FOUND, "❌권한 이슈❌ ROLE_MASTER 계정만 가능한 작업입니다."),
78
LOCATION_NOT_FOUND("404",HttpStatus.NOT_FOUND, "해당 투표리스트(장소)를 찾을 수 없습니다. locationId를 확인해주세요."),
89
SCHEDULE_MEMBER_NOT_FOUND("404",HttpStatus.NOT_FOUND, "스케줄에서 회원을 찾을 수 없습니다."),

0 commit comments

Comments
 (0)