Skip to content

Commit 0e697f8

Browse files
authored
fix : errorcode 수정 #122
2 parents c8e8301 + 134be9f commit 0e697f8

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

backend/src/main/java/com/back/domain/mission/exception/MissionException.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
package com.back.domain.mission.exception;
22

3+
import lombok.Getter;
34
import org.springframework.http.HttpStatus;
45

6+
7+
@Getter
58
public class MissionException extends RuntimeException{
69
private final HttpStatus httpStatus;
710
private final String code;
811
private final String message;
912

10-
public MissionException(MissionErrorCode memberErrorCode) {
11-
super(memberErrorCode.getMessage());
12-
this.httpStatus = memberErrorCode.getHttpStatus();
13-
this.code = memberErrorCode.getCode();
14-
this.message = memberErrorCode.getMessage();
13+
public MissionException(MissionErrorCode missionErrorCode) {
14+
super(missionErrorCode.getMessage());
15+
this.httpStatus = missionErrorCode.getHttpStatus();
16+
this.code = missionErrorCode.getCode();
17+
this.message = missionErrorCode.getMessage();
1518
}
1619

1720

backend/src/main/java/com/back/global/exception/GlobalExceptionHandler.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.back.global.exception;
22

3+
import com.back.domain.mission.exception.MissionException;
34
import com.back.global.common.ApiResponse;
45
import lombok.extern.slf4j.Slf4j;
56
import org.springframework.http.ResponseEntity;
@@ -49,4 +50,14 @@ public ResponseEntity<ApiResponse<Void>> handleException(Exception e) {
4950
.status(ErrorCode.INTERNAL_SERVER_ERROR.getHttpStatus())
5051
.body(response);
5152
}
53+
54+
@ExceptionHandler(MissionException.class)
55+
public ResponseEntity<ApiResponse<Void>> handlePetException(MissionException e) {
56+
log.info(e.getMessage(), e);
57+
ApiResponse<Void> response = ApiResponse.fail(
58+
e.getCode(),
59+
e.getMessage()
60+
);
61+
return ResponseEntity.status(e.getHttpStatus()).body(response);
62+
}
5263
}

0 commit comments

Comments
 (0)