Handlers.kt

  1. package com.hexagonkt.handlers

  2. import kotlin.reflect.KClass
  3. import kotlin.reflect.cast

  4. internal fun <T : Exception> castException(exception: Exception?, exceptionClass: KClass<T>): T =
  5.     exception
  6.         ?.let { exceptionClass.cast(exception) }
  7.         ?: error("Exception 'null' or incorrect type")