Skip to content

Commit

Permalink
[mod] #5 역직렬화 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
seokjun01 committed Jan 3, 2025
1 parent 52a2bc8 commit 7252c7d
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package com.example.eatmate.app.domain.member.domain;

import com.example.eatmate.global.config.error.ErrorCode;
import com.example.eatmate.global.config.error.exception.CommonException;
import com.example.eatmate.global.config.error.exception.custom.InvalidMbtiException;
import com.fasterxml.jackson.annotation.JsonCreator;

public enum Mbti {
ISTJ, ISFJ, INFJ, INTJ,
ISTP, ISFP, INFP, INTP,
ESTP, ESFP, ENFP, ENTP,
ESTJ, ESFJ, ENFJ, ENTJ;


@JsonCreator
public static Mbti fromString(String mbti) {

try {
return Mbti.valueOf(mbti.toUpperCase());
} catch (CommonException e) {
throw new InvalidMbtiException();
return Mbti.valueOf(mbti.toUpperCase().trim());
} catch (IllegalArgumentException e) {
throw new CommonException(ErrorCode.INVALID_MBTI);
}
}
}

0 comments on commit 7252c7d

Please sign in to comment.