belay
belay copied to clipboard
Robust error-handling for Kotlin and Android
A few people have been comparing parts of Belay to the Swift guard statement so I looked to see if there was any inspiration to be found there. Here in...
Using expectations instead of handlers, especially the global one, could cause infinite loops when they fail. ```kotlin expect.onGlobalFail = object : GlobalExpectationHandler() { override fun handleFail(exception: ExpectationException) { expect.fail("this will...
I've held off on updating Kotlin because Gradle 6.7 still uses Kotlin 1.3.72 and so using a library like Belay in a Gradle plugin can cause conflicts.
Rather than: ```kotlin fun countBananas(): Int { // Count the bananas. expect(bananaCount >= 0, "Invalid count: $bananaCount.") { bananaCount = 0 } return bananaCount } ``` Something like: ```kotlin fun...