Skip to content

Commit

Permalink
Merge pull request #363 from urinaner/feature/334
Browse files Browse the repository at this point in the history
[BE][FEAT] 멤버 로그인 예외 처리
  • Loading branch information
urinaner authored Feb 10, 2025
2 parents 016bf02 + 2478af9 commit 85ee11d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

@RequiredArgsConstructor
public enum MemberExceptionType implements BaseExceptionType {
DEPARTMENT_NOT_BIO(HttpStatus.BAD_REQUEST, "바이오융합공학과 소속이 아닙니다.");
DEPARTMENT_NOT_BIO(HttpStatus.BAD_REQUEST, "바이오융합공학과 소속이 아닙니다."),
INVALID_ID_OR_PASSWORD(HttpStatus.UNAUTHORIZED, "유효하지 않는 아이디 또는 비밀번호입니다."),
SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "서버 오류가 발생했습니다.");

private final HttpStatus httpStatus;
private final String errorMessage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.example.backend.users.service;

import static org.example.backend.users.exception.member.MemberExceptionType.DEPARTMENT_NOT_BIO;
import static org.example.backend.users.exception.member.MemberExceptionType.INVALID_ID_OR_PASSWORD;
import static org.example.backend.users.exception.member.MemberExceptionType.SERVER_ERROR;

import java.io.IOException;
import java.util.Map;
Expand Down Expand Up @@ -66,7 +68,7 @@ public SjUserProfile authenticate(LoginReqDto dto) throws AuthenticationExceptio
Connection.Response response = executeLoginRequest(dto);

if (response.statusCode() != 200) {
throw new RuntimeException("서버 오류가 발생했습니다: HTTP " + response.statusCode());
throw new MemberException(SERVER_ERROR);
}

return parseUserProfile(response.parse());
Expand All @@ -86,7 +88,7 @@ private Connection.Response executeLoginRequest(LoginReqDto dto) throws IOExcept
private SjUserProfile parseUserProfile(Document document) throws AuthenticationException {
Element userInfo = document.selectFirst("div.user-info-picture");
if (userInfo == null) {
throw new RuntimeException(AUTH_FAILED);
throw new MemberException(INVALID_ID_OR_PASSWORD);
}

Element nameElement = document.selectFirst("h4");
Expand Down

0 comments on commit 85ee11d

Please sign in to comment.