mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-03-12 13:22:23 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ae2c84c08 | |||
| b2e6ab51cb | |||
| d6496f02e6 | |||
| 38e98327b4 | |||
| c72a6fda5d |
21
CHANGELOG.md
21
CHANGELOG.md
@@ -1,7 +1,28 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.28.1
|
||||||
|
|
||||||
|
* `Coroutines`:
|
||||||
|
* `runCatchingLogging` updated to rethrow `CancellationException` and log other exceptions
|
||||||
|
|
||||||
## 0.28.0
|
## 0.28.0
|
||||||
|
|
||||||
|
**THIS VERSION CONTAINS BREAKING CHANGES DUE TO EXPOSED 1.0.0 UPDATE**
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `Kotlin`: `2.2.21` -> `2.3.0`
|
||||||
|
* `Serialization`: `1.9.0` -> `1.10.0`
|
||||||
|
* `Exposed`: `0.61.0` -> `1.0.0` (**MAJOR VERSION UPDATE**)
|
||||||
|
* `Ktor`: `3.3.3` -> `3.4.0`
|
||||||
|
* `NMCP`: `1.2.0` -> `1.2.1`
|
||||||
|
* `Repos`:
|
||||||
|
* `Exposed`:
|
||||||
|
* All Exposed-based repositories have been updated to support Exposed 1.0.0 API changes
|
||||||
|
* Import paths have been migrated to new `org.jetbrains.exposed.v1.*` package structure
|
||||||
|
* `Pagination`:
|
||||||
|
* `Exposed`:
|
||||||
|
* Updated to use new Exposed 1.0.0 import paths
|
||||||
|
|
||||||
## 0.27.0
|
## 0.27.0
|
||||||
|
|
||||||
* `Versions`:
|
* `Versions`:
|
||||||
|
|||||||
@@ -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.28.0
|
version=0.28.1
|
||||||
android_code_version=309
|
android_code_version=310
|
||||||
|
|||||||
Reference in New Issue
Block a user