-
Notifications
You must be signed in to change notification settings - Fork 0
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
๐ :: (#418) ์ ์ฒด ์์ธ ์ฒ๋ฆฌ #423
The head ref may contain hidden characters: "feature/418-\uC804\uCCB4-\uC608\uC678-\uCC98\uB9AC"
Conversation
Warning Rate limit exceeded@parkuiery has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 28 seconds before requesting another review. โ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. ๐ฆ How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. Walkthrough์ด ๋ณ๊ฒฝ ์ฌํญ์ Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? ๐ชง TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
๐งน Outside diff range and nitpick comments (2)
core/common/src/main/java/team/retum/common/exception/RequestExceptions.kt (1)
13-14
: ์๋ก์ด ์์ธ ํด๋์ค๋ค์ด ๊ธฐ์กด ๊ตฌ์กฐ์ ์ ํตํฉ๋์์ต๋๋ค.
UnknownException
์ ์์์น ๋ชปํ ์์ธ ์ํฉ์ ์ฒ๋ฆฌํ๋ ๋ฐ ์ ์ฉํ ๊ฒ ๊ฐ์ต๋๋ค.ReissueException
์ ํ ํฐ ๊ฐฑ์ ์คํจ๋ฅผ ๋ ๋ช ํํ๊ฒ ํํํ ์ ์๊ฒ ๋์์ต๋๋ค.๋ค๋ง, ๊ฐ ์์ธ ํด๋์ค์ ๋ํ ๋ฌธ์ํ(KDoc)๋ฅผ ์ถ๊ฐํ๋ฉด ๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค.
์์:
/** * ์์์น ๋ชปํ ์์ธ๊ฐ ๋ฐ์ํ์ ๋ ์ฌ์ฉ๋๋ ์์ธ ํด๋์ค์ ๋๋ค. */ data object UnknownException : RuntimeException() /** * ํ ํฐ ๊ฐฑ์ ๊ณผ์ ์์ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ ๋ ์ฌ์ฉ๋๋ ์์ธ ํด๋์ค์ ๋๋ค. */ data object ReissueException : RuntimeException()app/src/main/java/team/retum/jobisandroidv2/JobisExceptionHandler.kt (1)
11-14
: ๋ฌธ์์ด ๋ฆฌ์์ค ํ์ผ๋ก ์ค๋ฅ ๋ฉ์์ง ์ด๋ ํ์ํ์ฌ ํ๋์ฝ๋ฉ๋ ์ค๋ฅ ๋ฉ์์ง๋ค์
res/values/strings.xml
๋ก ์ด๋ํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด:
- ๋ค๊ตญ์ด ์ง์์ด ์ฉ์ดํด์ง๋๋ค
- ๋ฌธ์์ด ๊ด๋ฆฌ๊ฐ ๋ ์ฒด๊ณ์ ์ด ๋ฉ๋๋ค
- ๋ค๋ฅธ ํ๋ฉด์์๋ ์ฌ์ฌ์ฉ์ด ๊ฐ๋ฅํด์ง๋๋ค
๋ค์๊ณผ ๊ฐ์ด ๋ณ๊ฒฝํ๋ ๊ฒ์ ์ ์ํฉ๋๋ค:
-private const val InternetErrorMsg = "์ธํฐ๋ท ์ฐ๊ฒฐ์ ํ์ธํด์ฃผ์ธ์." -private const val TimeoutErrorMsg = "์์ฒญ ์๊ฐ์ด ์ด๊ณผ๋์์ต๋๋ค.\n๋ค์ ์๋ํด์ฃผ์ธ์." -private const val LoginErrorMsg = "์ ์ ์ ๋ณด๊ฐ ํ์ธ๋์ง ์์ต๋๋ค.\n๋ค์ ๋ก๊ทธ์ธ ํด์ฃผ์ธ์." -private const val UnknownErrorMsg = "์ฒ๋ฆฌ ์ค ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค.\n์ฑ์ ์ฌ์์ ํด์ฃผ์ธ์."strings.xml์ ์ถ๊ฐ:
<resources> <string name="error_internet">์ธํฐ๋ท ์ฐ๊ฒฐ์ ํ์ธํด์ฃผ์ธ์.</string> <string name="error_timeout">์์ฒญ ์๊ฐ์ด ์ด๊ณผ๋์์ต๋๋ค.\n๋ค์ ์๋ํด์ฃผ์ธ์.</string> <string name="error_login">์ ์ ์ ๋ณด๊ฐ ํ์ธ๋์ง ์์ต๋๋ค.\n๋ค์ ๋ก๊ทธ์ธ ํด์ฃผ์ธ์.</string> <string name="error_unknown">์ฒ๋ฆฌ ์ค ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค.\n์ฑ์ ์ฌ์์ ํด์ฃผ์ธ์.</string> </resources>
๐ Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
๐ Files selected for processing (5)
app/src/main/java/team/retum/jobisandroidv2/JobisExceptionHandler.kt
(1 hunks)app/src/main/java/team/retum/jobisandroidv2/MainActivity.kt
(1 hunks)core/common/src/main/java/team/retum/common/exception/RequestExceptions.kt
(1 hunks)core/network/src/main/java/team/retum/network/util/RefreshTokenService.kt
(2 hunks)core/network/src/main/java/team/retum/network/util/RequestHandler.kt
(2 hunks)
๐ Additional comments (5)
core/common/src/main/java/team/retum/common/exception/RequestExceptions.kt (1)
Line range hint 1-12
: ์์ธ ์ฒ๋ฆฌ ๊ตฌ์กฐ๊ฐ ์ ์ค๊ณ๋์ด ์์ต๋๋ค! ๐
๊ฐ๊ฐ์ ์์ธ ์ํฉ์ ๋ํด ๋ช ํํ๊ฒ ๊ตฌ๋ถ๋ ์์ธ ํด๋์ค๋ค์ด ์ ์ ์๋์ด ์์ผ๋ฉฐ, ์ผ๊ด๋ ํจํด์ ๋ฐ๋ฅด๊ณ ์์ต๋๋ค.
core/network/src/main/java/team/retum/network/util/RefreshTokenService.kt (1)
10-10
: LGTM!
์๋ก์ด ์์ธ ํ์ ์ import๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ์ถ๊ฐ๋์์ต๋๋ค.
core/network/src/main/java/team/retum/network/util/RequestHandler.kt (2)
14-14
: ์์ธ ์ฒ๋ฆฌ๋ฅผ ์ํ import ์ถ๊ฐ๊ฐ ์ ์ ํฉ๋๋ค.
UnknownException import ์ถ๊ฐ๋ ์ ์ฒด์ ์ธ ์์ธ ์ฒ๋ฆฌ ๊ฐ์ ๋ฐฉํฅ๊ณผ ์ผ์นํฉ๋๋ค.
67-67
: ๐ ๏ธ Refactor suggestion
์์ธ ์ฒ๋ฆฌ ๋์ ๋ณ๊ฒฝ์ ๋ํ ๊ฒ์ฆ์ด ํ์ํฉ๋๋ค.
๊ธฐ์กด ์์ธ๋ฅผ UnknownException์ผ๋ก ๋ํํ๋ ๊ฒ์ ์๋ฌ ์ถ์ ๊ณผ ๋๋ฒ๊น ์ ์ํฅ์ ๋ฏธ์น ์ ์์ต๋๋ค. ๋ค์ ์ฌํญ๋ค์ ํ์ธํด ์ฃผ์ธ์:
- ์๋ณธ ์์ธ ์ ๋ณด๊ฐ ์์ค๋์ง ์๋๋ก UnknownException ์์ฑ์์ ์์ธ ์์ธ๋ฅผ ์ ๋ฌํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
- ๋ก๊น ์์คํ ์์ ์ด๋ฌํ ์์ธ๋ค์ด ์ ์ ํ ๊ธฐ๋ก๋๋์ง ํ์ธ์ด ํ์ํฉ๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ์์ ํ๋ ๊ฒ์ ์ ์๋๋ฆฝ๋๋ค:
- throw UnknownException
+ throw UnknownException(cause = e)
์์ธ ์ฒ๋ฆฌ ๋ณ๊ฒฝ์ ์ํฅ์ ํ์ธํ๊ธฐ ์ํด ๋ค์ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํด๋ณด์ธ์:
app/src/main/java/team/retum/jobisandroidv2/MainActivity.kt (1)
52-55
: JobisExceptionHandler์ ๊ตฌํ์ ํ์ธํด์ฃผ์ธ์.
์์ธ ์ฒ๋ฆฌ๊ธฐ๊ฐ Context๋ฅผ ์ ์ ํ ์ฒ๋ฆฌํ๋์ง ํ์ธ์ด ํ์ํฉ๋๋ค.
๋ค์ ์คํฌ๋ฆฝํธ๋ก JobisExceptionHandler์ ๊ตฌํ์ ํ์ธํ๊ฒ ์ต๋๋ค:
โ Verification successful
Let me try another search to find the JobisExceptionHandler implementation:
Let me check the complete implementation including the makeToast method:
JobisExceptionHandler์ Context ์ฒ๋ฆฌ๊ฐ ์ ์ ํฉ๋๋ค.
JobisExceptionHandler์ ๊ตฌํ์ ๊ฒํ ํ ๊ฒฐ๊ณผ:
- Context๋ฅผ private ํ๋๋ก ์ ์ ํ ์บก์ํํ๊ณ ์์ต๋๋ค
- Context๋ ์ค์ง Toast ๋ฉ์์ง ํ์์๋ง ์ฌ์ฉ๋๋ฉฐ, ์ด๋ ์ผ๋ฐ์ ์ธ ์๋๋ก์ด๋ ํจํด์ ๋๋ค
- ๋ฉ๋ชจ๋ฆฌ ๋์๋ฅผ ์ผ์ผํฌ ์ ์๋ static ์ฐธ์กฐ๋ ์ฅ๊ธฐ ๋ณด๊ด์ด ์์ต๋๋ค
๐ Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify JobisExceptionHandler implementation for proper context handling
# Check how context is stored and used in JobisExceptionHandler
ast-grep --pattern 'class JobisExceptionHandler($context: Context) : Thread.UncaughtExceptionHandler {
$$$
}'
# Check for potential memory leaks by looking for strong references to context
rg -A 5 'context\.'
Length of output: 36918
Script:
#!/bin/bash
# Search for JobisExceptionHandler class implementation
rg -A 10 "class JobisExceptionHandler"
# Search for files that might contain JobisExceptionHandler
fd "JobisExceptionHandler"
Length of output: 1350
Script:
#!/bin/bash
# Get the complete implementation of JobisExceptionHandler
cat app/src/main/java/team/retum/jobisandroidv2/JobisExceptionHandler.kt
# Search for any strong references to context in the same file
rg "context\." app/src/main/java/team/retum/jobisandroidv2/JobisExceptionHandler.kt
Length of output: 1457
fun makeToast(message: String) { | ||
JobisToast.create( | ||
context = context, | ||
message = message, | ||
drawable = JobisIcon.Error, | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐ ๏ธ Refactor suggestion
Toast ๋ฉ์๋ ๊ฐ์์ฑ ๋ฐ ๊ธฐ๋ฅ ๊ฐ์ ํ์
makeToast
๋ฉ์๋์ ๋ํ ๊ฐ์ ์ฌํญ:
- ๋ฉ์๋๊ฐ public์ผ๋ก ์ ์ธ๋์ด ์์ด ๋ถํ์ํ ์ธ๋ถ ๋ ธ์ถ์ด ์์ต๋๋ค
- Toast ์ง์ ์๊ฐ์ ์ค์ ํ ์ ์์ต๋๋ค
๋ค์๊ณผ ๊ฐ์ด ๊ฐ์ ํ๋ ๊ฒ์ ์ ์ํฉ๋๋ค:
- fun makeToast(message: String) {
+ private fun makeToast(
+ message: String,
+ duration: Int = Toast.LENGTH_SHORT
+ ) {
JobisToast.create(
context = context,
message = message,
drawable = JobisIcon.Error,
+ duration = duration,
)
}
Committable suggestion skipped: line range outside the PR's diff.
override fun uncaughtException(t: Thread, e: Throwable) { | ||
when (e) { | ||
is OfflineException -> makeToast(InternetErrorMsg) | ||
is ConnectionTimeOutException -> makeToast(TimeoutErrorMsg) | ||
is ReissueException -> makeToast(LoginErrorMsg) | ||
is UnknownException -> makeToast(UnknownErrorMsg) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์์ธ ์ฒ๋ฆฌ ๊ฐ์ ํ์
ํ์ฌ ๊ตฌํ์์ ๋ช ๊ฐ์ง ๊ฐ์ ์ด ํ์ํฉ๋๋ค:
when
์์else
๋ถ๊ธฐ๊ฐ ์์ด ์ฒ๋ฆฌ๋์ง ์๋ ์์ธ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค- ๋๋ฒ๊น ์ ์ํ ๋ก๊น ์ด ์์ต๋๋ค
- ๋ ๊ตฌ์ฒด์ ์ธ ์์ธ ์ฒ๋ฆฌ๊ฐ ํ์ํ ์ ์์ต๋๋ค
๋ค์๊ณผ ๊ฐ์ด ๊ฐ์ ํ๋ ๊ฒ์ ์ ์ํฉ๋๋ค:
override fun uncaughtException(t: Thread, e: Throwable) {
+ Timber.e(e, "Uncaught exception occurred")
when (e) {
is OfflineException -> makeToast(InternetErrorMsg)
is ConnectionTimeOutException -> makeToast(TimeoutErrorMsg)
is ReissueException -> makeToast(LoginErrorMsg)
is UnknownException -> makeToast(UnknownErrorMsg)
+ else -> {
+ Timber.e(e, "Unhandled exception")
+ makeToast(UnknownErrorMsg)
+ }
}
}
๐ Committable suggestion
โผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
override fun uncaughtException(t: Thread, e: Throwable) { | |
when (e) { | |
is OfflineException -> makeToast(InternetErrorMsg) | |
is ConnectionTimeOutException -> makeToast(TimeoutErrorMsg) | |
is ReissueException -> makeToast(LoginErrorMsg) | |
is UnknownException -> makeToast(UnknownErrorMsg) | |
} | |
} | |
override fun uncaughtException(t: Thread, e: Throwable) { | |
Timber.e(e, "Uncaught exception occurred") | |
when (e) { | |
is OfflineException -> makeToast(InternetErrorMsg) | |
is ConnectionTimeOutException -> makeToast(TimeoutErrorMsg) | |
is ReissueException -> makeToast(LoginErrorMsg) | |
is UnknownException -> makeToast(UnknownErrorMsg) | |
else -> { | |
Timber.e(e, "Unhandled exception") | |
makeToast(UnknownErrorMsg) | |
} | |
} | |
} |
@@ -40,7 +41,7 @@ object RefreshTokenService { | |||
}.onSuccess { token -> | |||
return token | |||
}.onFailure { | |||
throw IllegalStateException("Fail refresh: ${it.message}") | |||
throw ReissueException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐ ๏ธ Refactor suggestion
์์ธ ์ฒ๋ฆฌ๋ฅผ ๊ฐ์ ํด ์ฃผ์ธ์.
ํ์ฌ ๊ตฌํ์ ์๋ ๋ฐ์ํ ์์ธ์ ์ ๋ณด๋ฅผ ๋ชจ๋ ์์ด๋ฒ๋ฆฝ๋๋ค. ๋๋ฒ๊น ๊ณผ ๋ฌธ์ ํด๊ฒฐ์ ์ํด ๋ค์๊ณผ ๊ฐ์ ๊ฐ์ ์ ์ ์ํฉ๋๋ค:
- ์์ธ์ด ๋๋ ์์ธ๋ฅผ ๋ณด์กด
- ์๋ฏธ ์๋ ์ค๋ฅ ๋ฉ์์ง ์ถ๊ฐ
- ๋ก๊น ์ถ๊ฐ
๋ค์๊ณผ ๊ฐ์ด ์์ ํ๋ ๊ฒ์ ์ถ์ฒ๋๋ฆฝ๋๋ค:
- throw ReissueException
+ throw ReissueException("ํ ํฐ ๊ฐฑ์ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค", it)
๋ํ ๋ก๊น ๊ตฌํ์ ์ํด Timber๋ ๋ค๋ฅธ ๋ก๊น ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๊ณ ๋ คํด๋ณด์ธ์.
Committable suggestion skipped: line range outside the PR's diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
๐งน Outside diff range and nitpick comments (2)
app/src/main/java/team/retum/jobisandroidv2/JobisExceptionHandler.kt (2)
11-14
: ๋ฌธ์์ด ๋ฆฌ์์ค ํ์ผ๋ก ์ด๋ ๊ถ์ฅ์ค๋ฅ ๋ฉ์์ง๋ฅผ
strings.xml
๋ฆฌ์์ค ํ์ผ๋ก ์ด๋ํ๋ ๊ฒ์ด ์ข์ต๋๋ค:
- ๋ค๊ตญ์ด ์ง์์ด ์ฉ์ดํด์ง๋๋ค
- ๋ฌธ์์ด ์ฌ์ฌ์ฉ์ด ๊ฐ๋ฅํด์ง๋๋ค
- ์ผ๊ด๋ ๋ฉ์์ง ๊ด๋ฆฌ๊ฐ ๊ฐ๋ฅํด์ง๋๋ค
์์:
<!-- strings.xml --> <resources> <string name="error_internet">์ธํฐ๋ท ์ฐ๊ฒฐ์ ํ์ธํด์ฃผ์ธ์.</string> <string name="error_timeout">์์ฒญ ์๊ฐ์ด ์ด๊ณผ๋์์ต๋๋ค.\n๋ค์ ์๋ํด์ฃผ์ธ์.</string> <string name="error_login">์ ์ ์ ๋ณด๊ฐ ํ์ธ๋์ง ์์ต๋๋ค.\n๋ค์ ๋ก๊ทธ์ธ ํด์ฃผ์ธ์.</string> <string name="error_unknown">์ฒ๋ฆฌ ์ค ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค.\n์ฑ์ ์ฌ์์ ํด์ฃผ์ธ์.</string> </resources>
16-18
: Context ์ฐธ์กฐ ๊ด๋ฆฌ ๊ฐ์ ํ์๋ฉ๋ชจ๋ฆฌ ๋์๋ฅผ ๋ฐฉ์งํ๊ธฐ ์ํด ๋ค์ ์ฌํญ์ ๊ณ ๋ คํด์ฃผ์ธ์:
ApplicationContext
๋ฅผ ์ฌ์ฉํ๋๋ก ๋ช ์์ ์ผ๋ก ์ ํ- Context ์ฐธ์กฐ๊ฐ ์ ์ ํ ํด์ ๋๋์ง ํ์ธ
class JobisExceptionHandler( - private val context: Context, + context: Context, ) : Thread.UncaughtExceptionHandler { + private val applicationContext = context.applicationContext
๐ Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
๐ Files selected for processing (2)
app/src/main/java/team/retum/jobisandroidv2/JobisExceptionHandler.kt
(1 hunks)app/src/main/java/team/retum/jobisandroidv2/MainActivity.kt
(1 hunks)
๐ง Files skipped from review as they are similar to previous changes (1)
- app/src/main/java/team/retum/jobisandroidv2/MainActivity.kt
private fun makeToast(message: String) { | ||
JobisToast.create( | ||
context = context, | ||
message = message, | ||
drawable = JobisIcon.Error, | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐ ๏ธ Refactor suggestion
Toast ํ์ ์์ ์ฑ ๊ฐ์ ํ์
Toast ๋ฉ์์ง ํ์์ ์์ ์ฑ์ ๋์ด๊ธฐ ์ํ ๊ฐ์ ์ฌํญ:
- ๋ฉ์ธ ์ค๋ ๋์์ ์คํ๋๋๋ก ๋ณด์ฅ
- Toast ์ง์ ์๊ฐ ์ค์ ์ต์ ์ถ๊ฐ
- ์คํจ ์ ๋์ฒด ์ฒ๋ฆฌ ๋ฐฉ์ ๊ณ ๋ ค
private fun makeToast(message: String) {
+ Handler(Looper.getMainLooper()).post {
+ try {
JobisToast.create(
context = context,
message = message,
drawable = JobisIcon.Error,
+ duration = Toast.LENGTH_LONG
)
+ } catch (e: Exception) {
+ Timber.e(e, "Failed to show toast")
+ }
+ }
}
๐ Committable suggestion
โผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
private fun makeToast(message: String) { | |
JobisToast.create( | |
context = context, | |
message = message, | |
drawable = JobisIcon.Error, | |
) | |
} | |
private fun makeToast(message: String) { | |
Handler(Looper.getMainLooper()).post { | |
try { | |
JobisToast.create( | |
context = context, | |
message = message, | |
drawable = JobisIcon.Error, | |
duration = Toast.LENGTH_LONG | |
) | |
} catch (e: Exception) { | |
Timber.e(e, "Failed to show toast") | |
} | |
} | |
} |
override fun uncaughtException(t: Thread, e: Throwable) { | ||
when (e) { | ||
is OfflineException -> makeToast(InternetErrorMsg) | ||
is ConnectionTimeOutException -> makeToast(TimeoutErrorMsg) | ||
is ReissueException -> makeToast(LoginErrorMsg) | ||
is UnknownException -> makeToast(UnknownErrorMsg) | ||
else -> makeToast(UnknownErrorMsg) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐ ๏ธ Refactor suggestion
์์ธ ๋ก๊น ์ถ๊ฐ ํ์
๋๋ฒ๊น ๊ณผ ๋ชจ๋ํฐ๋ง์ ์ํด ๋ก๊น ์ ์ถ๊ฐํ๋ ๊ฒ์ด ์ข์ต๋๋ค:
- ์์ธ ๋ฐ์ ์์ ๊ณผ ์์ธ ์ ๋ณด ๊ธฐ๋ก
- ์ค๋ ๋ ์ ๋ณด ํ์ฉ
- Crashlytics ๋ฑ์ ํฌ๋์ ๋ฆฌํฌํ ๋๊ตฌ ํตํฉ
override fun uncaughtException(t: Thread, e: Throwable) {
+ Timber.e(e, "Uncaught exception in thread ${t.name}")
when (e) {
is OfflineException -> makeToast(InternetErrorMsg)
is ConnectionTimeOutException -> makeToast(TimeoutErrorMsg)
is ReissueException -> makeToast(LoginErrorMsg)
is UnknownException -> makeToast(UnknownErrorMsg)
- else -> makeToast(UnknownErrorMsg)
+ else -> {
+ Timber.e(e, "Unhandled exception type: ${e.javaClass.simpleName}")
+ makeToast(UnknownErrorMsg)
+ }
}
}
๐ Committable suggestion
โผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
override fun uncaughtException(t: Thread, e: Throwable) { | |
when (e) { | |
is OfflineException -> makeToast(InternetErrorMsg) | |
is ConnectionTimeOutException -> makeToast(TimeoutErrorMsg) | |
is ReissueException -> makeToast(LoginErrorMsg) | |
is UnknownException -> makeToast(UnknownErrorMsg) | |
else -> makeToast(UnknownErrorMsg) | |
} | |
} | |
override fun uncaughtException(t: Thread, e: Throwable) { | |
Timber.e(e, "Uncaught exception in thread ${t.name}") | |
when (e) { | |
is OfflineException -> makeToast(InternetErrorMsg) | |
is ConnectionTimeOutException -> makeToast(TimeoutErrorMsg) | |
is ReissueException -> makeToast(LoginErrorMsg) | |
is UnknownException -> makeToast(UnknownErrorMsg) | |
else -> { | |
Timber.e(e, "Unhandled exception type: ${e.javaClass.simpleName}") | |
makeToast(UnknownErrorMsg) | |
} | |
} | |
} |
app/src/main/java/team/retum/jobisandroidv2/JobisExceptionHandler.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
๐งน Outside diff range and nitpick comments (2)
app/src/main/java/team/retum/jobisandroidv2/JobisApplication.kt (2)
25-41
: ์์ธ ์ฒ๋ฆฌ ๋ก์ง ๊ฐ์ ์ด ํ์ํฉ๋๋ค.ํ์ฌ ๊ตฌํ์ ๋ค์๊ณผ ๊ฐ์ ์ ์ฌ์ ์ธ ๋ฌธ์ ๊ฐ ์์ต๋๋ค:
exitProcess(0)
๋ฅผ ์ฆ์ ํธ์ถํ๋ฉด ์ฌ์ฉ์ ๋ฐ์ดํฐ๊ฐ ์์ค๋ ์ ์์ต๋๋ค- ๋ชจ๋ ์์ธ๋ฅผ ๋์ผํ ๋ฐฉ์์ผ๋ก ์ฒ๋ฆฌํ๋ ๊ฒ์ ์ฌ์ฉ์ ๊ฒฝํ์ ์ ํ์ํฌ ์ ์์ต๋๋ค
๋ค์๊ณผ ๊ฐ์ ๊ฐ์ ์ ์ ์๋๋ฆฝ๋๋ค:
- ์น๋ช ์ ์ธ ์ค๋ฅ์ ๋ณต๊ตฌ ๊ฐ๋ฅํ ์ค๋ฅ๋ฅผ ๊ตฌ๋ถํ์ฌ ์ฒ๋ฆฌ
- ์ฑ ์ข ๋ฃ ์ ์ ์ฌ์ฉ์ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๋ ๋ก์ง ์ถ๊ฐ
- ๋ณต๊ตฌ ๊ฐ๋ฅํ ๊ฒฝ์ฐ ๋ค์ด์ผ๋ก๊ทธ๋ฅผ ํตํด ์ฌ์ฉ์์๊ฒ ์ ํ๊ถ ์ ๊ณต
์์ ๊ตฌํ:
private fun handleFatalError(thread: Thread, exception: Throwable) { Firebase.crashlytics.recordException(exception) // ์ฌ์ฉ์ ๋ฐ์ดํฐ ์ ์ฅ saveApplicationState() // ๋ณต๊ตฌ ๊ฐ๋ฅํ ์ค๋ฅ์ธ ๊ฒฝ์ฐ if (isRecoverableError(exception)) { showRecoveryDialog(exception) return } // ์น๋ช ์ ์ธ ์ค๋ฅ์ธ ๊ฒฝ์ฐ showFatalErrorDialog { startActivity( Intent(this, MainActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK) } ) exitProcess(0) } }
44-50
: Toast ๋ฉ์์ง ํ์ ๋ฐฉ์ ๊ฐ์ ์ด ํ์ํฉ๋๋ค.ํ์ฌ ๊ตฌํ์ ์ฑ์ด ์ฌ์์๋๊ธฐ ์ ์ Toast ๋ฉ์์ง๊ฐ ์ฌ๋ผ์ง ์ ์์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ ๊ฐ์ ์ ์ ์๋๋ฆฝ๋๋ค:
private fun showErrorMessage(message: String) { // ๋ ๊ธด ์๊ฐ ๋์ ํ์ Toast.makeText(this, message, Toast.LENGTH_LONG).show() // ๋๋ Snackbar ์ฌ์ฉ val rootView = findViewById<View>(android.R.id.content) Snackbar.make(rootView, message, Snackbar.LENGTH_LONG).show() }
๐ Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
๐ Files selected for processing (1)
app/src/main/java/team/retum/jobisandroidv2/JobisApplication.kt
(1 hunks)
๐ Additional comments (1)
app/src/main/java/team/retum/jobisandroidv2/JobisApplication.kt (1)
4-13
: ํ์ํ import ๋ฌธ์ด ๋ชจ๋ ์ ์ถ๊ฐ๋์์ต๋๋ค!
์์ธ ์ฒ๋ฆฌ์ Firebase Crashlytics ํตํฉ์ ์ํ import ๋ฌธ์ด ์ ์ ํ๊ฒ ํฌํจ๋์ด ์์ต๋๋ค.
private const val InternetErrorMsg = "์ธํฐ๋ท ์ฐ๊ฒฐ์ ํ์ธํด์ฃผ์ธ์." | ||
private const val TimeoutErrorMsg = "์์ฒญ ์๊ฐ์ด ์ด๊ณผ๋์์ต๋๋ค.\n๋ค์ ์๋ํด์ฃผ์ธ์." | ||
private const val LoginErrorMsg = "์ ์ ์ ๋ณด๊ฐ ํ์ธ๋์ง ์์ต๋๋ค.\n๋ค์ ๋ก๊ทธ์ธ ํด์ฃผ์ธ์." | ||
private const val UnknownErrorMsg = "์ฒ๋ฆฌ ์ค ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐ ๏ธ Refactor suggestion
๋ฌธ์์ด ๋ฆฌ์์ค ๊ด๋ฆฌ ๊ฐ์ ์ด ํ์ํฉ๋๋ค.
ํ๋์ฝ๋ฉ๋ ์๋ฌ ๋ฉ์์ง๋ฅผ res/values/strings.xml
๋ก ์ด๋ํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด:
- ๋ค๊ตญ์ด ์ง์์ด ์ฉ์ดํด์ง๋๋ค
- ๋ฌธ์์ด ์ฌ์ฌ์ฉ์ด ๊ฐ๋ฅํด์ง๋๋ค
- ์ผ๊ด๋ ๋ฉ์์ง ๊ด๋ฆฌ๊ฐ ๊ฐ๋ฅํด์ง๋๋ค
๋ค์๊ณผ ๊ฐ์ด ๋ณ๊ฒฝํ๋ ๊ฒ์ ์ ์๋๋ฆฝ๋๋ค:
-private const val InternetErrorMsg = "์ธํฐ๋ท ์ฐ๊ฒฐ์ ํ์ธํด์ฃผ์ธ์."
-private const val TimeoutErrorMsg = "์์ฒญ ์๊ฐ์ด ์ด๊ณผ๋์์ต๋๋ค.\n๋ค์ ์๋ํด์ฃผ์ธ์."
-private const val LoginErrorMsg = "์ ์ ์ ๋ณด๊ฐ ํ์ธ๋์ง ์์ต๋๋ค.\n๋ค์ ๋ก๊ทธ์ธ ํด์ฃผ์ธ์."
-private const val UnknownErrorMsg = "์ฒ๋ฆฌ ์ค ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค."
strings.xml์ ์ถ๊ฐ:
<resources>
<string name="error_internet">์ธํฐ๋ท ์ฐ๊ฒฐ์ ํ์ธํด์ฃผ์ธ์.</string>
<string name="error_timeout">์์ฒญ ์๊ฐ์ด ์ด๊ณผ๋์์ต๋๋ค.\n๋ค์ ์๋ํด์ฃผ์ธ์.</string>
<string name="error_login">์ ์ ์ ๋ณด๊ฐ ํ์ธ๋์ง ์์ต๋๋ค.\n๋ค์ ๋ก๊ทธ์ธ ํด์ฃผ์ธ์.</string>
<string name="error_unknown">์ฒ๋ฆฌ ์ค ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค.</string>
</resources>
๊ฐ์
์ ์ฒด ์์ธ ์ฒ๋ฆฌ๋ฅผ ์ถ๊ฐํ์์ต๋๋ค.
์์ ๋ด์ฉ
ํ ๋ง
Summary by CodeRabbit
UnknownException
๋ฐReissueException
์์ธ ์ถ๊ฐ๋ก ์ค๋ฅ ์ฒ๋ฆฌ ๊ธฐ๋ฅ ๊ฐํ.