Skip to main content

Typed Error Handling in Kotlin

· One min read
Typed Error Handling in Kotlin

A comparative study about several typed-error handling practices in Kotlin.

There are various approaches to error handling in the Kotlin community. In this article we’ve explored a small subset of typed error handling practices in the community.

From the approaches explored, there were three patterns that aligns with Kotlin recommendation with relatively low cognitive complexity including: Sealed class matching with early returns, Arrow's either { } builder, and Arrow's context(Raise<E>) with context-receivers.

Arrow's context(Raise<E>) achieved the most optimized score on all aspects of developer productivity. This includes having the lowest cognitive complexity, the lowest cyclomatic complexity as well as the most succinct with the least lines of codes.

Read the full article: Typed Error Handling in Kotlin.