g-market / b-shop-backend

0 stars 0 forks source link

feat: 공통적인 exception에 대한 핸들링 및 추가 - [merged] #60

Closed halucinor closed 1 year ago

halucinor commented 1 year ago

In GitLab by @haaeee on Feb 12, 2023, 14:28

Merges refactoring/exception -> develop

작업 내용

주의사항

Closes #25

halucinor commented 1 year ago

In GitLab by @haaeee on Feb 12, 2023, 14:28

requested review from @rkdud1108

halucinor commented 1 year ago

In GitLab by @haaeee on Feb 12, 2023, 14:29

다 같이 이에 대해서 얘기해보고 수정할 부분 수정하고 Merge하면 될 것 같습니다!

halucinor commented 1 year ago

In GitLab by @halucinor on Feb 12, 2023, 18:03

Commented on src/main/java/com/gabia/bshop/exception/ApplicationException.java line 10

CustomException -> ApplicationException 으로 명칭을 변경한 이유가 있을까요?

halucinor commented 1 year ago

In GitLab by @halucinor on Feb 12, 2023, 18:57

Commented on src/main/java/com/gabia/bshop/exception/ApplicationException.java line 17

[제안] 파라미터에 따른 메시지 변경이 필요한경우 ApplicationException 생성자를 오버로딩해서 해결하는 건 어떨까요?

//ErrorCode.java

    MAX_PAGE_ELEMENT_REQUEST_SIZE_EXCEPTION(CONFLICT, "한 페이지의 최대 {0}개까지 조회가 가능합니다.")
//ConflictException.java
public class ConflictException extends ApplicationException {
    public ConflictException(final ErrorCode errorCode) {
        super(errorCode);
    }
    public ConflictException(final ErrorCode errorCode, final String str) {
        super(errorCode, str);
    }
}
//Application.java
    protected ApplicationException(final ErrorCode errorCode) {
        this.httpStatus = errorCode.getHttpStatus();
        this.exceptionResponse = new ExceptionResponse(errorCode.getMessage());
    }

    protected ApplicationException(final ErrorCode errorCode, final String str) {
        this.httpStatus = errorCode.getHttpStatus();
        this.exceptionResponse = new ExceptionResponse(String.format(errorCode.getMessage(), str));
    }
//OrderController.java
    private void validatePageElementSize(final Pageable pageable) {
        if (pageable.getPageSize() > MAX_PAGE_ELEMENT_REQUEST_SIZE) {
            throw new ConflictException(MAX_PAGE_ELEMENT_REQUEST_SIZE_EXCEPTION, "100");
        }
    }
halucinor commented 1 year ago

In GitLab by @rkdud1108 on Feb 12, 2023, 19:34

Commented on src/main/java/com/gabia/bshop/exception/ErrorCode.java line 50

'상품이 이미 취소된 상태입니다'로 바꾸는 건 어떨까요?

halucinor commented 1 year ago

In GitLab by @rkdud1108 on Feb 12, 2023, 19:43

Commented on src/main/java/com/gabia/bshop/exception/ErrorCode.java line 52

위의 에러들에 대해 409로 처리하는게 맞을까요?

위와 같은 경우들에 대해 어떤 에러코드를 던져주는게 맞을지 논의가 필요해 보입니다. 아래의 글과 같은 의견도 있어서 참고 부탁드립니다~ https://brainbackdoor.tistory.com/137

halucinor commented 1 year ago

In GitLab by @rkdud1108 on Feb 12, 2023, 19:44

Commented on src/main/java/com/gabia/bshop/service/AuthService.java line 74

이 에러 메세지는 공통 Exception 파일에서 관리하지 않는 이유가 있을까요?

halucinor commented 1 year ago

In GitLab by @rkdud1108 on Feb 12, 2023, 19:50

Commented on src/test/java/com/gabia/bshop/service/AuthServiceTest.java line 230

@DisplayName으로 변경 부탁드립니다.

halucinor commented 1 year ago

In GitLab by @halucinor on Feb 13, 2023, 10:02

Commented on src/main/java/com/gabia/bshop/exception/ErrorCode.java line 50

changed this line in version 2 of the diff

halucinor commented 1 year ago

In GitLab by @halucinor on Feb 13, 2023, 10:02

Commented on src/main/java/com/gabia/bshop/exception/ErrorCode.java line 52

changed this line in version 2 of the diff

halucinor commented 1 year ago

In GitLab by @halucinor on Feb 13, 2023, 10:02

Commented on src/main/java/com/gabia/bshop/service/AuthService.java line 74

changed this line in version 2 of the diff

halucinor commented 1 year ago

In GitLab by @halucinor on Feb 13, 2023, 10:02

added 1 commit

Compare with previous version

halucinor commented 1 year ago

In GitLab by @halucinor on Feb 13, 2023, 10:34

Commented on src/main/java/com/gabia/bshop/exception/ErrorCode.java line 50

수정해서 반영했습니다.

halucinor commented 1 year ago

In GitLab by @halucinor on Feb 13, 2023, 10:35

Commented on src/test/java/com/gabia/bshop/service/AuthServiceTest.java line 230

테스트 명칭 변경을 위한 이슈와 브랜치를 따로 생성해 처리하겠습니다.

halucinor commented 1 year ago

In GitLab by @halucinor on Feb 13, 2023, 10:36

Commented on src/main/java/com/gabia/bshop/service/AuthService.java line 74

EntityNotFoundException을 사용하지 않기로 의사결정하였습니다. 따라서, 해당 코드는 NotFoundException으로 공통 Exception 에서 관리하도록 변경하겠습니다.

halucinor commented 1 year ago

In GitLab by @halucinor on Feb 13, 2023, 10:37

Commented on src/main/java/com/gabia/bshop/exception/ApplicationException.java line 10

모든 어플리케이션레벨에서 공통적으로 사용하는 추상 예외처리 클래스이므로 명칭을 변경하였다고 확인하였습니다.

halucinor commented 1 year ago

In GitLab by @halucinor on Feb 13, 2023, 10:39

Commented on src/main/java/com/gabia/bshop/exception/ApplicationException.java line 17

오버로딩을 사용해 메시지를 추가적인 매개변수를 통해 변경하는 로직으로 수정하기로 결정했습니다. 추가 commit에서 해당내용 반영했습니다.

halucinor commented 1 year ago

In GitLab by @halucinor on Feb 13, 2023, 10:41

Commented on src/main/java/com/gabia/bshop/exception/ErrorCode.java line 52

사용자 요청이 정상적으로 받아들여져 200번으로 리턴코드를 주는 1안, 사용자 요청이 정상적으로 받아들여졌지만, 서버의 자원 상태에 따라 정상적으로 처리되지 않음을 명시하기위해 409번으로 에러코드를 주는 2안을 고민한 결과 보다 직관적으로 사용자 요청이 정상적으로 받아들여지지 않음을 명시하는 409로 에러코드를 반환하는 것으로 의사결정하였습니다. :)

halucinor commented 1 year ago

In GitLab by @rkdud1108 on Feb 13, 2023, 12:02

resolved all threads

halucinor commented 1 year ago

In GitLab by @haaeee on Feb 13, 2023, 13:04

added 2 commits

Compare with previous version

halucinor commented 1 year ago

In GitLab by @rkdud1108 on Feb 13, 2023, 13:11

approved this merge request

halucinor commented 1 year ago

In GitLab by @rkdud1108 on Feb 13, 2023, 13:11

enabled an automatic merge when the pipeline for c93fd630b6a4466dd8a79b067ecd4a0f2acd0a47 succeeds

halucinor commented 1 year ago

In GitLab by @haaeee on Feb 13, 2023, 13:11

mentioned in commit 3d033b43d9780fa6c4a05b16c70e332e71af735a

halucinor commented 1 year ago

In GitLab by @rkdud1108 on Feb 13, 2023, 13:11

mentioned in commit 8f7ba14e92be839c5a25e60fc33c2ef0a4f13f33

halucinor commented 1 year ago

In GitLab by @halucinor on Feb 21, 2023, 12:59

mentioned in commit 9a043ac60e0ac7fde962795a9ff59eaf4f2e8b42

halucinor commented 1 year ago

In GitLab by @haaeee on Mar 7, 2023, 10:00

mentioned in commit 07d25fd7dbcc3ecadd855f90f140b2f2b61d3c1f

halucinor commented 1 year ago

In GitLab by @halucinor on Mar 8, 2023, 17:23

mentioned in commit 2e0e481faed37aba8c40035da5d200b28c6ed1af

halucinor commented 1 year ago

In GitLab by @halucinor on Mar 8, 2023, 22:35

mentioned in commit 9b6efe6bde5fbf30a19e6118d5a5900e2e962383

halucinor commented 1 year ago

In GitLab by @rkdud1108 on Mar 18, 2023, 12:58

mentioned in commit f69407b6bce153198d48f198c33983b58b0e3a85