1

In a quarkus/kotlin app, I have a rest client that is very basic:

@Path("/my/api/v1")
@RestClient
interface MyApiClient { }

Problem is, when a request fails, it returns a response that fails to be mapped. So I want to add an exception mapper, in order to log the real error:

class MyExceptionMapper : ResponseExceptionMapper<java.lang.RuntimeException?> {
    override fun toThrowable(r: Response): java.lang.RuntimeException {
        Logger.getLogger(MyApiClient::class.java).error(r.status)
        return RuntimeException("failed")
    }
}

To do so, I should annoate my client with:

@RegisterProvider(MyExceptionMapper::class.java)

Doing so, I have a kotlin error:

An annotation argument must be a compile-time constant

I googled but could find solutions only for strings. In this case, kotlin expects the java class to be a compile time constant. How to get it?

Rolintocour
  • 2,934
  • 4
  • 32
  • 63
  • Using the solution from @Михаил_Нафталь, did you get this ever to work? What did you do? My ResponseExceptionMapper doesn't work :( – Shinigami Jan 09 '23 at 13:30

1 Answers1

1

Should work with simple:

@RegisterProvider(MyExceptionMapper::class)