avro-kotlin / avro4k

Avro format support for Kotlin
Apache License 2.0
198 stars 37 forks source link

Improve error understandability when exception thrown during schema generation #267

Open Chuckame opened 1 month ago

Chuckame commented 1 month ago

Is your feature request related to a problem? Please describe. As seen in #264, the error weren't explicit at all, especially when you don't know how works the kotlinx serialization library.

Here an example of error:

com.github.avrokotlin.avro4k.internal.AvroSchemaGenerationException: Polymorphic descriptor 'ContextDescriptor(kClass: class kotlinx.serialization.KSerializer, original: kotlinx.serialization.Polymorphic(type: kotlin.String, value: kotlinx.serialization.Polymorphic<KSerializer>))' must have at least one possible schema

Describe the solution you'd like We have to add the path of this error, to be able to locate well the error as it could be deep in the classes hierarchy.