Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

에러 핸들링 관련 리팩터링 및 에러 코드를 추가합니다. #35

Merged
merged 3 commits into from
Feb 3, 2024

Conversation

litsynp
Copy link
Contributor

@litsynp litsynp commented Feb 2, 2024

에러 핸들링 관련 리팩터링 및 에러 코드를 추가합니다.

  • 이제 message 외에 code라는 필드를 Error Response로 같이 반환합니다. pnd 패키지에서 enum으로 관리합니다.

  • chi/render를 사용하며, render.Renderer 인터페이스를 구현하는 커스텀 에러인 AppError를 추가합니다.

  • 에러의 정확한 원인에서부터 status code를 유추할 때가 많아 그냥 repository 단부터 AppError를 반환합니다. 좋은 패턴이라고 생각하진 않지만 일단 편의를 위해서... 더 좋은 방향은 추후 생각해보면 좋을 것 같습니다.

  • database/sql의 PG Error은 FromPGError(err errror) 내에서 strings.Contains로 처리합니다.

@litsynp litsynp added feat New feature refactor Outer changes to codes labels Feb 2, 2024
@litsynp litsynp requested a review from barabobBOB February 2, 2024 17:25
@litsynp litsynp self-assigned this Feb 2, 2024
@litsynp
Copy link
Contributor Author

litsynp commented Feb 2, 2024

@litsynp litsynp force-pushed the feat/error-code branch 2 times, most recently from 62602b1 to b3521bb Compare February 3, 2024 01:17
Copy link
Member

@barabobBOB barabobBOB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추가로 돌봄급구 서비스단에서 사용하던 시간 포맷 함수도 common에 추가하고 모두 util 함수로 이용하도록 수정했습니다.

@litsynp
Copy link
Contributor Author

litsynp commented Feb 3, 2024

추가로 돌봄급구 서비스단에서 사용하던 시간 포맷 함수도 common에 추가하고 모두 util 함수로 이용하도록 수정했습니다.

@barabobBOB 앗... 요것은 제 브랜치인데 ㅋㅋㅋ 원래는 크게 상관 없지만 요 브랜치에 의존하는 PR들이 좀 있어서.. 다음엔 따로 PR 파서 진행 부탁드려요!

@litsynp litsynp requested a review from barabobBOB February 3, 2024 16:21
@barabobBOB
Copy link
Member

@litsynp 헉 알겠습니다..!

@litsynp
Copy link
Contributor Author

litsynp commented Feb 3, 2024

@barabobBOB 괜찮아요~ 괜찮으면 어프룹 부탁드립니다 🙇

Copy link
Member

@barabobBOB barabobBOB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존보다 훨씬 에러코드가 명시적이여서 좋네요 :)

@litsynp
Copy link
Contributor Author

litsynp commented Feb 3, 2024

🙇

@litsynp litsynp merged commit 780bad3 into main Feb 3, 2024
1 check passed
@litsynp litsynp deleted the feat/error-code branch February 3, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature refactor Outer changes to codes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants