All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.kotest.assertions.exceptionToMessage.kt Maven / Gradle / Ivy

package io.kotest.assertions

/**
 * Returns a string error message from the given throwable.
 * If the type is an [AssertionError] then the message is taken from the exceptions own message,
 * otherwise the exception is converted to a string.
 */
fun exceptionToMessage(t: Throwable): String =
   when (t) {
      is AssertionError -> when (t.message) {
         null -> t.toString()
         else -> t.message!!
      }
      else -> t.toString()
   }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy