Skip to content

Commit eab41a3

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

10 files changed

+34
-181
lines changed

src/main/java/com/grepp/spring/infra/error/eventAdvice/EventExceptionAdvice.java

Lines changed: 0 additions & 108 deletions
This file was deleted.
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.event;
22

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

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

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

1514
public AlreadyConfirmedScheduleException(EventErrorCode code, Exception e) {
16-
this.code = code;
17-
log.error(e.getMessage(), e);
15+
super(code, e);
1816
}
1917

20-
public EventErrorCode code() {
21-
return code;
22-
}
2318
}
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.event;
22

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

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

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

1514
public AlreadyJoinedEventException(EventErrorCode code, Exception e) {
16-
this.code = code;
17-
log.error(e.getMessage(), e);
15+
super(code, e);
1816
}
1917

20-
public EventErrorCode code() {
21-
return code;
22-
}
2318
}
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.event;
22

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

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

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

1514
public EventAlreadyCompletedException(EventErrorCode code, Exception e) {
16-
this.code = code;
17-
log.error(e.getMessage(), e);
15+
super(code, e);
1816
}
1917

20-
public EventErrorCode code() {
21-
return code;
22-
}
2318
}
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.event;
22

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

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

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

1514
public EventAuthenticationException(EventErrorCode code, Exception e) {
16-
this.code = code;
17-
log.error(e.getMessage(), e);
15+
super(code, e);
1816
}
1917

20-
public EventErrorCode code() {
21-
return code;
22-
}
2318
}
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.event;
22

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

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

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

1514
public EventNotFoundException(EventErrorCode code, Exception e) {
16-
this.code = code;
17-
log.error(e.getMessage(), e);
15+
super(code, e);
1816
}
1917

20-
public EventErrorCode code() {
21-
return code;
22-
}
2318
}
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.event;
22

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

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

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

1514
public InvalidEventDataException(EventErrorCode code, Exception e) {
16-
this.code = code;
17-
log.error(e.getMessage(), e);
15+
super(code, e);
1816
}
1917

20-
public EventErrorCode code() {
21-
return code;
22-
}
2318
}
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.event;
22

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

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

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

1514
public NotEventMemberException(EventErrorCode code, Exception e) {
16-
this.code = code;
17-
log.error(e.getMessage(), e);
15+
super(code, e);
1816
}
1917

20-
public EventErrorCode code() {
21-
return code;
22-
}
2318
}
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
package com.grepp.spring.infra.error.exceptions.event;
22

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

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

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

1514
public ScheduleResultNotFoundException(EventErrorCode code, Exception e) {
16-
this.code = code;
17-
log.error(e.getMessage(), e);
15+
super(code, e);
1816
}
1917

20-
public EventErrorCode code() {
21-
return code;
22-
}
2318
}

src/main/java/com/grepp/spring/infra/response/EventErrorCode.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 EventErrorCode {
6+
public enum EventErrorCode implements ErrorCode {
67
INVALID_EVENT_DATA("400", HttpStatus.BAD_REQUEST, "잘못된 이벤트 데이터입니다."),
78
ALREADY_CONFIRMED_SCHEDULE("400", HttpStatus.BAD_REQUEST, "이미 확정된 일정입니다."),
89
CANNOT_COMPLETE_EMPTY_SCHEDULE("400", HttpStatus.BAD_REQUEST, "빈 일정은 확정할 수 없습니다."),

0 commit comments

Comments
 (0)