mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-06-18 01:05:10 +00:00
Compare commits
1 Commits
v0.26.9
...
f0a51ae7ad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0a51ae7ad |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -1,20 +1,5 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 0.26.9
|
|
||||||
|
|
||||||
* `Coroutines`:
|
|
||||||
* `runCatchingLogging` updated to rethrow `CancellationException` and log other exceptions
|
|
||||||
|
|
||||||
## 0.26.8
|
|
||||||
|
|
||||||
* `Versions`:
|
|
||||||
* `KSLog`: `1.5.1` -> `1.5.2`
|
|
||||||
* `Compose`: `1.9.2` -> `1.9.3`
|
|
||||||
* `Ktor`: `3.3.1` -> `3.3.2`
|
|
||||||
* `Coroutines`:
|
|
||||||
* Add simple suspend function `suspendPoint` which will ensure that current coroutine is active to let it be
|
|
||||||
destroyable even in case it have non-suspendable nature
|
|
||||||
|
|
||||||
## 0.26.7
|
## 0.26.7
|
||||||
|
|
||||||
* `Versions`:
|
* `Versions`:
|
||||||
|
|||||||
@@ -2,27 +2,11 @@ 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 {
|
||||||
when (it) {
|
logger.e(it) { errorMessageBuilder(it) }
|
||||||
is CancellationException -> throw it
|
|
||||||
else -> logger.e(it) { errorMessageBuilder(it) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
package dev.inmo.micro_utils.coroutines
|
|
||||||
|
|
||||||
import kotlinx.coroutines.currentCoroutineContext
|
|
||||||
import kotlinx.coroutines.ensureActive
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ensures that the current coroutine context is still active and throws a [kotlinx.coroutines.CancellationException]
|
|
||||||
* if the coroutine has been canceled.
|
|
||||||
*
|
|
||||||
* This function provides a convenient way to check the active status of a coroutine, which is useful
|
|
||||||
* to identify cancellation points in long-running or suspendable operations.
|
|
||||||
*
|
|
||||||
* @throws kotlinx.coroutines.CancellationException if the coroutine context is no longer active.
|
|
||||||
*/
|
|
||||||
suspend fun suspendPoint() = currentCoroutineContext().ensureActive()
|
|
||||||
@@ -18,5 +18,5 @@ crypto_js_version=4.1.1
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.26.9
|
version=0.26.7
|
||||||
android_code_version=307
|
android_code_version=306
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ kt-coroutines = "1.10.2"
|
|||||||
|
|
||||||
kotlinx-browser = "0.5.0"
|
kotlinx-browser = "0.5.0"
|
||||||
|
|
||||||
kslog = "1.5.2"
|
kslog = "1.5.1"
|
||||||
|
|
||||||
jb-compose = "1.9.3"
|
jb-compose = "1.9.2"
|
||||||
jb-compose-material3 = "1.9.0"
|
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"
|
||||||
@@ -20,7 +20,7 @@ sqlite = "3.50.1.0"
|
|||||||
korlibs = "5.4.0"
|
korlibs = "5.4.0"
|
||||||
uuid = "0.8.4"
|
uuid = "0.8.4"
|
||||||
|
|
||||||
ktor = "3.3.2"
|
ktor = "3.3.1"
|
||||||
|
|
||||||
gh-release = "2.5.2"
|
gh-release = "2.5.2"
|
||||||
|
|
||||||
@@ -28,13 +28,13 @@ koin = "4.1.1"
|
|||||||
|
|
||||||
okio = "3.16.2"
|
okio = "3.16.2"
|
||||||
|
|
||||||
ksp = "2.3.2"
|
ksp = "2.3.1"
|
||||||
kotlin-poet = "2.2.0"
|
kotlin-poet = "2.2.0"
|
||||||
|
|
||||||
versions = "0.53.0"
|
versions = "0.52.0"
|
||||||
nmcp = "1.2.0"
|
nmcp = "1.2.0"
|
||||||
|
|
||||||
android-gradle = "8.12.+"
|
android-gradle = "8.13.+"
|
||||||
dexcount = "4.0.0"
|
dexcount = "4.0.0"
|
||||||
|
|
||||||
android-coreKtx = "1.17.0"
|
android-coreKtx = "1.17.0"
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
kotlin {
|
kotlin {
|
||||||
androidTarget {
|
androidTarget {
|
||||||
publishLibraryVariants(
|
publishAllLibraryVariants()
|
||||||
"release",
|
|
||||||
"debug",
|
|
||||||
)
|
|
||||||
compilations.all {
|
compilations.all {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "17"
|
jvmTarget = "17"
|
||||||
|
|||||||
Reference in New Issue
Block a user