Skip to content

Commit

Permalink
feat: Add exception handling (#19)
Browse files Browse the repository at this point in the history
Co-authored-by: chaeeun-Han <[email protected]>
  • Loading branch information
Ahyun0326 and chaeeun-Han committed Mar 19, 2024
1 parent 2ccc636 commit bcdae12
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/beotkkot/qtudy/common/ResponseCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public interface ResponseCode {
String VALIDATION_FAILED = "VF";
String NOT_EXISTED_USER = "NEU";
String NOT_EXISTED_POST = "NEP";
String NOT_EXISTED_COMMENT = "NEC";

// HTTP Status 401
String SIGN_IN_FAIL = "SF";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public interface ResponseMessage {
String VALIDATION_FAILED = "Validation Failed.";
String NOT_EXISTED_USER = "This user does not exist.";
String NOT_EXISTED_POST = "This post does not exist.";
String NOT_EXISTED_COMMENT = "This comment does not exist.";

// HTTP Status 401
String SIGN_IN_FAIL = "Login information mismatch.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ public static ResponseEntity<ResponseDto> noPermission() {
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(result);
}

public static ResponseEntity<ResponseDto> noAuthentication() {
ResponseDto result = new ResponseDto(ResponseCode.AUTHORIZATION_FAIL, ResponseMessage.AUTHORIZATION_FAIL);
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(result);
}

}

0 comments on commit bcdae12

Please sign in to comment.