Compare commits

..

3 Commits

4 changed files with 27 additions and 15 deletions

View File

@@ -1,13 +1,9 @@
# Changelog
## 0.27.0
## 0.26.9
* `Versions`:
* `Ktor`: `3.3.2` -> `3.3.3`
* `Okio`: `3.16.2` -> `3.16.4`
* `KSP`: `2.3.2` -> `2.3.4`
* `Compose`: `1.9.3` -> `1.10.0`
* `Compose Material3`: `1.9.0` -> `1.10.0-alpha05`
* `Coroutines`:
* `runCatchingLogging` updated to rethrow `CancellationException` and log other exceptions
## 0.26.8

View File

@@ -2,11 +2,27 @@ package dev.inmo.micro_utils.coroutines
import dev.inmo.kslog.common.KSLog
import dev.inmo.kslog.common.e
import kotlin.coroutines.cancellation.CancellationException
/**
* Executes the given [block] within a `runCatching` context and logs any exceptions that occur, excluding
* `CancellationException` which is rethrown. This method simplifies error handling by automatically logging
* the errors using the provided [logger].
*
* @param T The result type of the [block].
* @param R The receiver type on which this function operates.
* @param errorMessageBuilder A lambda to build the error log message. By default, it returns a generic error message.
* @param logger The logging instance used for logging errors. Defaults to [KSLog].
* @param block The code block to execute within the `runCatching` context.
* @return A [Result] representing the outcome of executing the [block].
*/
inline fun <T, R> R.runCatchingLogging(
noinline errorMessageBuilder: R.(Throwable) -> Any = { "Something web wrong" },
logger: KSLog = KSLog,
block: R.() -> T
) = runCatching(block).onFailure {
logger.e(it) { errorMessageBuilder(it) }
when (it) {
is CancellationException -> throw it
else -> logger.e(it) { errorMessageBuilder(it) }
}
}

View File

@@ -18,5 +18,5 @@ crypto_js_version=4.1.1
# Project data
group=dev.inmo
version=0.27.0
android_code_version=308
version=0.26.9
android_code_version=307

View File

@@ -8,8 +8,8 @@ kotlinx-browser = "0.5.0"
kslog = "1.5.2"
jb-compose = "1.10.0"
jb-compose-material3 = "1.10.0-alpha05"
jb-compose = "1.9.3"
jb-compose-material3 = "1.9.0"
jb-compose-icons = "1.7.8"
jb-exposed = "0.61.0"
jb-dokka = "2.1.0"
@@ -20,15 +20,15 @@ sqlite = "3.50.1.0"
korlibs = "5.4.0"
uuid = "0.8.4"
ktor = "3.3.3"
ktor = "3.3.2"
gh-release = "2.5.2"
koin = "4.1.1"
okio = "3.16.4"
okio = "3.16.2"
ksp = "2.3.4"
ksp = "2.3.2"
kotlin-poet = "2.2.0"
versions = "0.53.0"