How does one catch JsonDecodingException? seems like it is internal to kotlinx
bjonnh
01/20/2021, 7:00 PM
I guess you just have to catch a SerializationException…
v
Vsevolod Tolstopyatov [JB]
01/25/2021, 12:18 PM
Yeah, we recommend working with
SerializationException
instead,
JsonDecodingException
is just for better debuggability and diagnostics, not for programmatic use
b
bjonnh
01/26/2021, 8:33 PM
I was using that for a tryMultipleTimes<T>(times: Int, exceptions:
List<KClass<out Exception>>
, f: ()->T):T
bjonnh
01/26/2021, 8:33 PM
that would retry a certain number of times if it receive an exception from that list
bjonnh
01/26/2021, 8:33 PM
but I can't do it with JsonDecodingException as I was doing:
listExceptions.any { e::class == it }
bjonnh
01/26/2021, 8:34 PM
I added a "text" based selector based on the java qualified so I can still catch that one, not the best way, but I'm not certain how to do that better.
bjonnh
01/26/2021, 8:35 PM
I could also catch and re throw my own exception I guess