mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-03-13 05:42:23 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| abbc38a2c2 | |||
| 6e320ebcf8 | |||
| df95f78bb3 |
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,13 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 0.27.0
|
## 0.26.9
|
||||||
|
|
||||||
* `Versions`:
|
* `Coroutines`:
|
||||||
* `Ktor`: `3.3.2` -> `3.3.3`
|
* `runCatchingLogging` updated to rethrow `CancellationException` and log other exceptions
|
||||||
* `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`
|
|
||||||
|
|
||||||
## 0.26.8
|
## 0.26.8
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,27 @@ package dev.inmo.micro_utils.coroutines
|
|||||||
|
|
||||||
import dev.inmo.kslog.common.KSLog
|
import dev.inmo.kslog.common.KSLog
|
||||||
import dev.inmo.kslog.common.e
|
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(
|
inline fun <T, R> R.runCatchingLogging(
|
||||||
noinline errorMessageBuilder: R.(Throwable) -> Any = { "Something web wrong" },
|
noinline errorMessageBuilder: R.(Throwable) -> Any = { "Something web wrong" },
|
||||||
logger: KSLog = KSLog,
|
logger: KSLog = KSLog,
|
||||||
block: R.() -> T
|
block: R.() -> T
|
||||||
) = runCatching(block).onFailure {
|
) = runCatching(block).onFailure {
|
||||||
logger.e(it) { errorMessageBuilder(it) }
|
when (it) {
|
||||||
|
is CancellationException -> throw it
|
||||||
|
else -> logger.e(it) { errorMessageBuilder(it) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ crypto_js_version=4.1.1
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.27.0
|
version=0.26.9
|
||||||
android_code_version=308
|
android_code_version=307
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ kotlinx-browser = "0.5.0"
|
|||||||
|
|
||||||
kslog = "1.5.2"
|
kslog = "1.5.2"
|
||||||
|
|
||||||
jb-compose = "1.10.0"
|
jb-compose = "1.9.3"
|
||||||
jb-compose-material3 = "1.10.0-alpha05"
|
jb-compose-material3 = "1.9.0"
|
||||||
jb-compose-icons = "1.7.8"
|
jb-compose-icons = "1.7.8"
|
||||||
jb-exposed = "0.61.0"
|
jb-exposed = "0.61.0"
|
||||||
jb-dokka = "2.1.0"
|
jb-dokka = "2.1.0"
|
||||||
@@ -20,15 +20,15 @@ sqlite = "3.50.1.0"
|
|||||||
korlibs = "5.4.0"
|
korlibs = "5.4.0"
|
||||||
uuid = "0.8.4"
|
uuid = "0.8.4"
|
||||||
|
|
||||||
ktor = "3.3.3"
|
ktor = "3.3.2"
|
||||||
|
|
||||||
gh-release = "2.5.2"
|
gh-release = "2.5.2"
|
||||||
|
|
||||||
koin = "4.1.1"
|
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"
|
kotlin-poet = "2.2.0"
|
||||||
|
|
||||||
versions = "0.53.0"
|
versions = "0.53.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user