← Docs
kotlin-stdlib / kotlin / Result / exceptionOrNull

exceptionOrNull

Common
JVM
JS
Native
1.0
fun exceptionOrNull ( ) : Throwable ?
(source)

Returns the encapsulated Throwable exception if this instance represents failure or null if it is success .

This function is a shorthand for fold(onSuccess = { null }, onFailure = { it }) (see fold ).

Stay in touch:
  • Contributing to Kotlin
  • Releases
  • Press Kit
  • Security
  • Blog
  • Issue Tracker
  • Brand assets
  • Careers
Supported and developed by JetBrains .
Kotlin™ is protected under the Kotlin Foundation
and licensed under the Apache 2 license .