Skip to content

Commit

Permalink
feat: enhance the exception handling when build opencc dictionaries
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiredPlanck committed Mar 16, 2024
1 parent 3baf674 commit f2c9d1c
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,16 @@ object OpenCCDictManager {
fun buildOpenCCDict() {
for (d in getAllDictionaries()) {
if (d is TextDictionary) {
val result: OpenCCDictionary
val result: Result<OpenCCDictionary>
measureTimeMillis {
result = d.toOpenCCDictionary()
}.also { Timber.d("Took $it to convert to $result") }
result = runCatching { d.toOpenCCDictionary() }
}.also {
result.onSuccess { r ->
Timber.d("Took $it to convert to $r")
}.onFailure {
Timber.e(it, "Failed to convert $d")
}
}
}
}
}
Expand Down

0 comments on commit f2c9d1c

Please sign in to comment.