Throw exception for a Functional Interface in kotlin

Viewed 648

I am new to the Kotlin and now I try to migrate an app from Java to Kotlin. I have the following interface in java

  public interface FunctionWithExceptions<T, R, E extends Exception> {

    R apply(T t) throws E;
  }

and when I translate it to Kotlin I have the following code

    interface FunctionWithExceptions<T, R, E : Exception?> {
        @Throws(E::class)
        fun apply(t: T): R

    }

but I have the following error: Cannot use 'E' as reified type parameter. Use a class instead. could you please let me know how to fix it

0 Answers
Related