Skip to content

Commit

Permalink
Merge pull request #48 from tukcomCD2024/Ringo-144
Browse files Browse the repository at this point in the history
Ringo 144
  • Loading branch information
KangJiSseok authored May 13, 2024
2 parents cd8c17f + 2ef7e50 commit de7607a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .idea/modules/webChat.main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/modules/webChat.test.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 3 additions & 16 deletions BackEnd/src/main/java/springwebsocket/webchat/error/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,16 @@ public enum ErrorCode {
// -----예외(Http 상태, 에러코드, 메시지)------ //

// Member
EMAIL_ALREADY_TAKEN(400, "M001", "이미 존재하는 이메일입니다."),
// USER_NAME_NOT_FOUND(400, "M004", "해당 이름의 사용자를 찾을수 없습니다."),
// EMAIL_USER_NOT_FOUND(400, "M005", "해당 이메일의 사용자가 존재하지 않습니다."),
// EMAIL_EMPTY(400, "M007", "이메일을 입력해주세요."),

EMAIL_ALREADY_TAKEN("이미 존재하는 이메일입니다."),

//Friend
FRIEND_ALREADT_TAKEN(400, "M011", "이미 친구 요청을 보낸 상대입니다.");
// INVALID_LOGIN_INFO(400, "M009", "이메일 또는 비밀번호를 다시 확인해 주세요."),
// UNAUTHORIZED_USER(401, "M010", "로그인 후 이용가능합니다."),
// USER_EMPTY(400, "M011", "존재하지 않는 사용자입니다."),
// LOGIN_AGAIN(400, "M012", "로그인을 다시 시도해 주세요");
//
FRIEND_ALREADT_TAKEN("이미 친구 요청을 보낸 상대입니다.");



private final int httpStatus;
private final String code;
private final String message;

ErrorCode(final int httpStatus, final String code, final String message) {
this.httpStatus = httpStatus;
this.code = code;
ErrorCode(final String message) {
this.message = message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public class FriendExceptionController {

@ExceptionHandler(FriendDuplicationException.class)
public ResponseEntity<ExceptionResponse> DataIntegrityViolationException(FriendDuplicationException e){
log.info("DataIntegrityViolationException");
ExceptionResponse exceptionResponse = new ExceptionResponse(e.getErrorCode());
return ResponseEntity.status(exceptionResponse.getStatus()).body(exceptionResponse);
return ResponseEntity.ok(exceptionResponse);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,12 @@
import springwebsocket.webchat.error.ErrorCode;

public class ExceptionResponse {
private final int status;
private final String code;
private final String message;

public ExceptionResponse(ErrorCode exceptionCode) {
this.status = exceptionCode.getHttpStatus();
this.code = exceptionCode.getCode();
this.message = exceptionCode.getMessage();
}

public int getStatus() {
return status;
}

public String getCode() {
return code;
}

public String getMessage() {
return message;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public class ExceptionController {
@ExceptionHandler(EmailDuplicatedException.class)
public ResponseEntity<ExceptionResponse> EmailDuplicatedException(EmailDuplicatedException e) {
ExceptionResponse exceptionResponse = new ExceptionResponse(e.getErrorCode());
return ResponseEntity.status(exceptionResponse.getStatus()).body(exceptionResponse);
return ResponseEntity.ok(exceptionResponse);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public UserResponse signUp(SignUpRequest signUpRequest) {
Member member = new Member(email, password, name, "ROLE_ADMIN");
try {
memberRepository.save(member);
log.info("member ={}", member.getEmail());
} catch (DataIntegrityViolationException ex) {
log.info("DataIntegrityViolationException");
throw new EmailDuplicatedException(email);

}
Expand Down

0 comments on commit de7607a

Please sign in to comment.