Skip to content

Commit c2d6c92

Browse files
committed
Merge branch 'develop' into BOOK-364-feature/#193
2 parents 70770ed + 6914f44 commit c2d6c92

File tree

47 files changed

+148
-90
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+148
-90
lines changed

build-logic/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class AndroidLibraryComposeConventionPlugin : Plugin<Project> {
1212
applyPlugins(
1313
Plugins.ANDROID_LIBRARY,
1414
Plugins.KOTLIN_COMPOSE,
15+
Plugins.COMPOSE_STABILITY_ANALYZER,
1516
)
1617

1718
extensions.configure<LibraryExtension> {

build-logic/src/main/kotlin/com/ninecraft/booket/convention/Plugins.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ object Plugins {
1111
const val ANDROID_APPLICATION = "com.android.application"
1212
const val ANDROID_LIBRARY = "com.android.library"
1313

14+
const val COMPOSE_STABILITY_ANALYZER = "com.github.skydoves.compose.stability.analyzer"
15+
1416
const val HILT = "dagger.hilt.android.plugin"
1517
const val KSP = "com.google.devtools.ksp"
1618
const val GOOGLE_SERVICES = "com.google.gms.google-services"

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
alias(libs.plugins.gradle.dependency.handler.extensions)
66
alias(libs.plugins.kotlin.detekt)
77
alias(libs.plugins.kotlin.ktlint)
8+
alias(libs.plugins.compose.stability.analyzer) apply false
89
alias(libs.plugins.kotlin.parcelize) apply false
910
alias(libs.plugins.kotlin.android) apply false
1011
alias(libs.plugins.kotlin.compose) apply false

core/common/src/main/kotlin/com/ninecraft/booket/core/common/constants/ErrorDialogSpec.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.ninecraft.booket.core.common.constants
33
import androidx.annotation.StringRes
44

55
data class ErrorDialogSpec(
6+
val title: String? = null,
67
val message: String,
78
@StringRes val buttonLabelResId: Int,
89
val action: () -> Unit,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.ninecraft.booket.core.common.constants
22

33
enum class ErrorScope {
4-
GLOBAL, LOGIN, BOOK_REGISTER, RECORD_REGISTER
4+
GLOBAL, LOGIN, AUTH_SESSION_EXPIRED,
55
}

core/common/src/main/kotlin/com/ninecraft/booket/core/common/extensions/Context.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import androidx.core.content.FileProvider
1616
import com.orhanobut.logger.Logger
1717
import java.io.File
1818

19-
@Suppress("TooGenericExceptionCaught")
2019
fun Context.externalShareForBitmap(bitmap: ImageBitmap) {
2120
try {
2221
val file = File(bitmap.saveToDisk(this))
@@ -31,7 +30,6 @@ fun Context.externalShareForBitmap(bitmap: ImageBitmap) {
3130
}
3231
}
3332

34-
@Suppress("TooGenericExceptionCaught")
3533
fun Context.saveImageToGallery(bitmap: ImageBitmap) {
3634
try {
3735
val fileName = "reed_record_${System.currentTimeMillis()}.png"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.ninecraft.booket.core.common.extensions
2+
3+
import com.ninecraft.booket.core.common.utils.ErrorType
4+
import com.ninecraft.booket.core.common.utils.isNetworkError
5+
6+
fun Throwable.toErrorType(): ErrorType {
7+
return if (this.isNetworkError()) {
8+
ErrorType.NetworkError
9+
} else {
10+
ErrorType.ServerError
11+
}
12+
}

core/common/src/main/kotlin/com/ninecraft/booket/core/common/util/EmotionAnalyzer.kt renamed to core/common/src/main/kotlin/com/ninecraft/booket/core/common/utils/EmotionAnalyzer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.ninecraft.booket.core.common.util
1+
package com.ninecraft.booket.core.common.utils
22

33
import com.ninecraft.booket.core.model.EmotionModel
44

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.ninecraft.booket.core.common.utils
2+
3+
import androidx.compose.runtime.Immutable
4+
5+
@Immutable
6+
sealed interface ErrorType {
7+
data object NetworkError : ErrorType
8+
data object ServerError : ErrorType
9+
}

core/common/src/main/kotlin/com/ninecraft/booket/core/common/utils/HandleException.kt

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ fun handleException(
2323
) {
2424
when {
2525
exception is HttpException && exception.code() == 401 -> {
26-
onLoginRequired()
26+
postErrorDialog(
27+
errorScope = ErrorScope.AUTH_SESSION_EXPIRED,
28+
exception = exception,
29+
action = {
30+
onLoginRequired()
31+
},
32+
)
2733
}
2834

2935
exception is HttpException -> {
@@ -51,56 +57,42 @@ fun postErrorDialog(
5157
@StringRes buttonLabelResId: Int = R.string.confirm,
5258
action: () -> Unit = {},
5359
) {
54-
val spec = buildDialog(
55-
scope = errorScope,
56-
exception = exception,
57-
buttonLabelResId = buttonLabelResId,
58-
action = action,
59-
)
60-
61-
ErrorEventHelper.sendError(event = ErrorEvent.ShowDialog(spec))
62-
}
63-
64-
private fun buildDialog(
65-
scope: ErrorScope,
66-
exception: Throwable,
67-
@StringRes buttonLabelResId: Int,
68-
action: () -> Unit,
69-
): ErrorDialogSpec {
70-
val message = when {
60+
val (title, message) = when {
7161
exception.isNetworkError() -> {
72-
"네트워크 연결이 불안정합니다.\n인터넷 연결을 확인해주세요"
62+
null to "네트워크 연결이 불안정합니다.\n인터넷 연결을 확인해주세요"
7363
}
7464

7565
exception is HttpException -> {
76-
when (scope) {
66+
when (errorScope) {
7767
ErrorScope.GLOBAL -> {
78-
"알 수 없는 문제가 발생했어요.\n다시 시도해주세요"
68+
null to "알 수 없는 문제가 발생했어요.\n다시 시도해주세요"
7969
}
8070

8171
ErrorScope.LOGIN -> {
82-
"예기치 않은 오류가 발생했습니다.\n다시 로그인 해주세요."
72+
"로그인 오류" to "예기치 않은 오류가 발생했습니다.\n다시 로그인 해주세요."
8373
}
8474

85-
ErrorScope.BOOK_REGISTER -> {
86-
"도서 등록 중 오류가 발생했어요.\n다시 시도해주세요"
87-
}
88-
89-
ErrorScope.RECORD_REGISTER -> {
90-
"기록 저장에 실패했어요.\n다시 시도해주세요"
75+
ErrorScope.AUTH_SESSION_EXPIRED -> {
76+
null to "세션이 만료되었어요.\n다시 로그인 해주세요"
9177
}
9278
}
9379
}
9480

9581
else -> {
96-
"알 수 없는 문제가 발생했어요.\n다시 시도해주세요"
82+
null to "알 수 없는 문제가 발생했어요.\n다시 시도해주세요"
9783
}
9884
}
9985

100-
return ErrorDialogSpec(message = message, buttonLabelResId = buttonLabelResId, action = action)
86+
val spec = ErrorDialogSpec(
87+
title = title,
88+
message = message,
89+
buttonLabelResId = buttonLabelResId,
90+
action = action,
91+
)
92+
93+
ErrorEventHelper.sendError(event = ErrorEvent.ShowDialog(spec))
10194
}
10295

103-
@Suppress("TooGenericExceptionCaught")
10496
private fun HttpException.parseErrorMessage(): String? {
10597
return try {
10698
val errorBody = response()?.errorBody()?.string()

0 commit comments

Comments
 (0)