File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed
backend/src/main/java/com/back Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 11package com .back .domain .mission .exception ;
22
3+ import lombok .Getter ;
34import org .springframework .http .HttpStatus ;
45
6+
7+ @ Getter
58public 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
Original file line number Diff line number Diff line change 11package com .back .global .exception ;
22
3+ import com .back .domain .mission .exception .MissionException ;
34import com .back .global .common .ApiResponse ;
45import lombok .extern .slf4j .Slf4j ;
56import 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}
You can’t perform that action at this time.
0 commit comments