-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 에러 핸들링 및 공통 UI 처리 #118
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
719d2f1
[BOOK-233] feat: 공통 에러 화면 구현
seoyoon513 c269da9
[BOOK-233] feat: 홈, 내서재 공통 에러 화면 적용
seoyoon513 a8bc3ff
[BOOK-233] feat: 도서 검색, 내서재 검색 공통 에러 화면 적용
seoyoon513 5ec258d
[BOOK-233] feat: 기록 상세 공통 에러 화면 적용
seoyoon513 e4b59d2
[BOOK-233] feat: 기록 상세 화면에서 emotion 그래픽 매핑
seoyoon513 738322f
[BOOK-233] feat: EventBus를 통한 전역 에러 핸들링 구성
seoyoon513 c7e4c64
[BOOK-233] feat: 도서 등록, 기록 등록에서 에러 발생 시 에러 다이얼로그 띄우기
seoyoon513 d107c81
[BOOK-233] refactor: 도서 상세 화면에서 초기 로드를 async로 구현
seoyoon513 5067573
[BOOK-233] refactor: 내서재에서 동일 필터 누를 시 early return 처리 및 진입 때마다 초기 로드 진행
seoyoon513 7136609
[BOOK-233] feat: 도서 상세 화면에서 기록 화면으로 이동 시 userBookId 넘기기
seoyoon513 5debfeb
[BOOK-233] chore: code style check success
seoyoon513 5f94120
[BOOK-233] refactor: 토끼 리뷰 반영
seoyoon513 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
core/common/src/main/kotlin/com/ninecraft/booket/core/common/constants/ErrorDialogSpec.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.ninecraft.booket.core.common.constants | ||
|
|
||
| data class ErrorDialogSpec( | ||
| val message: String, | ||
| val buttonLabel: String, | ||
| val action: () -> Unit, | ||
| ) |
5 changes: 5 additions & 0 deletions
5
core/common/src/main/kotlin/com/ninecraft/booket/core/common/constants/ErrorScope.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.ninecraft.booket.core.common.constants | ||
|
|
||
| enum class ErrorScope { | ||
| GLOBAL, LOGIN, BOOK_REGISTER, RECORD_REGISTER | ||
| } |
22 changes: 22 additions & 0 deletions
22
core/common/src/main/kotlin/com/ninecraft/booket/core/common/event/ErrorEventHelper.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package com.ninecraft.booket.core.common.event | ||
|
|
||
| import com.ninecraft.booket.core.common.constants.ErrorDialogSpec | ||
| import kotlinx.coroutines.channels.Channel | ||
| import kotlinx.coroutines.flow.receiveAsFlow | ||
| import java.util.UUID | ||
|
|
||
| object ErrorEventHelper { | ||
| private val _errorEvent = Channel<ErrorEvent>(DEFAULT_BUFFER_SIZE) | ||
| val errorEvent = _errorEvent.receiveAsFlow() | ||
|
|
||
| fun sendError(event: ErrorEvent) { | ||
| _errorEvent.trySend(event) | ||
| } | ||
| } | ||
|
|
||
| sealed interface ErrorEvent { | ||
| data class ShowDialog( | ||
| val spec: ErrorDialogSpec, | ||
| val key: String = UUID.randomUUID().toString(), | ||
| ) : ErrorEvent | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
core/ui/src/main/kotlin/com/ninecraft/booket/core/ui/component/ReedErrorUi.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package com.ninecraft.booket.core.ui.component | ||
|
|
||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.Spacer | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.text.style.TextAlign | ||
| import com.ninecraft.booket.core.common.utils.isNetworkError | ||
| import com.ninecraft.booket.core.designsystem.ComponentPreview | ||
| import com.ninecraft.booket.core.designsystem.component.button.ReedButton | ||
| import com.ninecraft.booket.core.designsystem.component.button.ReedButtonColorStyle | ||
| import com.ninecraft.booket.core.designsystem.component.button.mediumButtonStyle | ||
| import com.ninecraft.booket.core.designsystem.theme.ReedTheme | ||
| import com.ninecraft.booket.core.ui.R | ||
|
|
||
| @Composable | ||
| fun ReedErrorUi( | ||
| exception: Throwable, | ||
| onRetryClick: () -> Unit, | ||
| ) { | ||
| val message = if (exception.isNetworkError()) stringResource(R.string.network_error_message) else stringResource(R.string.server_error_message) | ||
| Box( | ||
| modifier = Modifier.fillMaxSize(), | ||
| contentAlignment = Alignment.Center, | ||
| ) { | ||
| Column(horizontalAlignment = Alignment.CenterHorizontally) { | ||
| Text( | ||
| text = message, | ||
| color = ReedTheme.colors.contentSecondary, | ||
| textAlign = TextAlign.Center, | ||
| style = ReedTheme.typography.body1Medium, | ||
| ) | ||
| Spacer(modifier = Modifier.height(ReedTheme.spacing.spacing6)) | ||
| ReedButton( | ||
| onClick = { onRetryClick() }, | ||
| text = stringResource(R.string.retry), | ||
| colorStyle = ReedButtonColorStyle.PRIMARY, | ||
| sizeStyle = mediumButtonStyle, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @ComponentPreview | ||
| @Composable | ||
| private fun ReedNetworkErrorUiPreview() { | ||
| ReedErrorUi( | ||
| exception = java.io.IOException("네트워크 오류"), | ||
| onRetryClick = {}, | ||
| ) | ||
| } | ||
|
|
||
| @ComponentPreview | ||
| @Composable | ||
| private fun ReedServerErrorUiPreview() { | ||
| ReedErrorUi( | ||
| exception = Exception("알 수 없는 문제"), | ||
| onRetryClick = {}, | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.