Replace error return object with Kotlin version