icerockdev / moko-errors

Automated exceptions handler for mobile (android & ios) Kotlin Multiplatform development.
https://moko.icerock.dev/
Apache License 2.0
52 stars 6 forks source link

Add fallback factory #25

Closed RezMike closed 1 year ago

RezMike commented 3 years ago

Now you can only specify a fallback value:

ExceptionMappersStorage.setFallbackValue(MR.strings.common_unknownError.desc())

Another option is to add a fallback factory:

ExceptionMappersStorage.setFallbackFactory { error : Throwable ->
    if (error.message.isNullOrBlank()) {
        MR.strings.common_unknownError.desc()
    } else {
        error.message!!.desc()
    }
}
Alex009 commented 1 year ago

will be released in 0.7.0