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

네트워크 에러 핸들링 #164

Merged
merged 21 commits into from
Nov 24, 2023
Merged

네트워크 에러 핸들링 #164

merged 21 commits into from
Nov 24, 2023

Conversation

2taezeat
Copy link
Collaborator

@2taezeat 2taezeat commented Nov 23, 2023

Issue

Overview

Copy link

github-actions bot commented Nov 23, 2023

Test Results

4 tests   4 ✔️  1s ⏱️
1 suites  0 💤
1 files    0

Results for commit ac71697.

♻️ This comment has been updated with latest results.

Comment on lines 7 to 9

@Qualifier
annotation class ErrorInterceptor
Copy link
Member

Choose a reason for hiding this comment

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

파일 이름을 일반적인 인터셉터 이름으로 고치거나, 어노테이션을 별도 클래스로 분리하면 좋을 것 같아

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

반영했습니다~

Copy link
Member

@HamBP HamBP left a comment

Choose a reason for hiding this comment

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

굿굿

@2taezeat 2taezeat changed the title Android/feature/111 네트워크 에러 핸들링 Nov 23, 2023
@2taezeat 2taezeat added ✨ feat 기능 개발 🤖 android android labels Nov 23, 2023
@2taezeat 2taezeat self-assigned this Nov 23, 2023
@2taezeat 2taezeat added this to the 🔧 etc milestone Nov 23, 2023
@2taezeat 2taezeat linked an issue Nov 23, 2023 that may be closed by this pull request
@2taezeat
Copy link
Collaborator Author

2taezeat commented Nov 24, 2023

추가로 11.24(금) 아침에 논의 했던,
서버에서 errorCode를 줄 수 없고, statusCode 를 주는 경우에 대한, errorInterceptor 예외 처리를 하였습니다.

이에 대해서 automaticallyLogin 호출 테스트로, 개발한 예외 처리 동작 잘 되는지 확인하였습니다~

Comment on lines 61 to 81
protected fun fetchCtErrorMessageId(ctErrorType: CtErrorType): Int {
return when (ctErrorType) {
CtErrorType.DUPLICATED_NICKNAME -> R.string.error_message_duplicated_nickname
CtErrorType.WRONG_TOKEN -> R.string.error_message_wrong_token
CtErrorType.SERVER -> R.string.error_message_server
CtErrorType.CONNECTION -> R.string.error_message_connection
CtErrorType.IO -> R.string.error_message_io
CtErrorType.SSL_HAND_SHAKE -> R.string.error_message_ssl_hand_shake
CtErrorType.UN_KNOWN -> R.string.error_message_un_known
CtErrorType.UN_AUTHORIZED -> R.string.error_message_un_authorized
CtErrorType.NOT_EXIST_PLAYLIST_ON_USER -> R.string.error_message_not_exist_playlist_on_user
CtErrorType.NOT_EXIST_MUSIC -> R.string.error_message_not_exist_music
CtErrorType.ALREADY_ADDED -> R.string.error_message_already_added
CtErrorType.INVALID_INPUT_VALUE -> R.string.error_message_invalid_input_value
CtErrorType.NOT_EXIST_USER -> R.string.error_message_not_exist_user
CtErrorType.ALREADY_EXIST_EMAIL -> R.string.error_message_already_exist_email
CtErrorType.NOT_EXIST_GENRE -> R.string.error_message_not_exist_genre
CtErrorType.EXPIRED_TOKEN -> R.string.error_message_expired_token
CtErrorType.SERVICE -> R.string.error_message_service
}
}
Copy link
Member

Choose a reason for hiding this comment

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

저는 이부분이 부모 클래스에 있는 것 보다는 다른 파일로 분리해서 이 역할을 따로 분리했으면 좋겠다는 생각이드네용! 확장함수를 사용해도 좋을 것 같아요

Comment on lines 70 to 73
is LoginEvent.ShowMessage -> {
val messageId = fetchCtErrorMessageId(event.error)
showMessage(messageId)
}
Copy link
Member

Choose a reason for hiding this comment

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

위에 코멘트 반영해서 showMessage(event.error.toMsgId()) 하면 가독성이 더 좋아질 것 같아요🙂

Comment on lines 45 to 53
if (throwable is CtException) {
_events.emit(LoginEvent.ShowMessage(throwable.ctError))
val ctError = throwable.ctError
if (ctError == CtErrorType.NOT_EXIST_USER || ctError == CtErrorType.WRONG_TOKEN) {
_events.emit(LoginEvent.NavigateToNickName(token))
}
} else {
_events.emit(LoginEvent.ShowMessage(CtErrorType.UN_KNOWN))
}
Copy link
Member

Choose a reason for hiding this comment

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

이 로직을 위에 exception Handler 에 포함시켜도 되지 않을까요?? 조건문 하나 빼고는 위에 로직이랑 같은 것 같아요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

반영했습니다~

Copy link
Member

@youlalala youlalala left a comment

Choose a reason for hiding this comment

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

정말 많은 고민이 담긴 코드 같아 보이네요 ㅎㅎ!! 고생하셨어요!@@ 👏🏻

@2taezeat 2taezeat merged commit 419c8fa into develop Nov 24, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android android ✨ feat 기능 개발
Projects
None yet
Development

Successfully merging this pull request may close these issues.

네트워크 에러 핸들링
3 participants