Skip to content

Commit b53c3e2

Browse files
authored
Merge pull request #37 from icerockdev/#23-add-fast-getting-mapped-value
#23 added new extension for getting exception description
2 parents d0be859 + de92fd8 commit b53c3e2

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ allprojects {
4444
project build.gradle
4545
```groovy
4646
dependencies {
47-
commonMainApi("dev.icerock.moko:errors:0.4.0")
47+
commonMainApi("dev.icerock.moko:errors:0.5.0")
4848
}
4949
```
5050

errors/src/commonMain/kotlin/dev/icerock/moko/errors/mappers/ExceptionMappersStorage.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,11 @@ object ExceptionMappersStorage {
167167
inline fun <E : Throwable, reified T : Any> throwableMapper(): (e: E) -> T {
168168
return throwableMapper(T::class)
169169
}
170+
171+
/**
172+
* Factory method that allows getting exception description
173+
*/
174+
inline fun <reified E : Throwable, reified T : Any> E.mapThrowable(): T {
175+
return ExceptionMappersStorage.throwableMapper<E, T>(T::class)(this)
176+
}
170177
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ androidCoreTestingVersion = "2.1.0"
77
coroutinesVersion = "1.5.0-native-mt"
88
mokoMvvmVersion = "0.11.0"
99
mokoResourcesVersion = "0.16.0"
10-
mokoErrorsVersion = "0.4.0"
10+
mokoErrorsVersion = "0.5.0"
1111

1212
[libraries]
1313
appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidAppCompatVersion" }

0 commit comments

Comments
 (0)