micronaut-serialization icon indicating copy to clipboard operation
micronaut-serialization copied to clipboard

Ability to customize error messages

Open driverpt opened this issue 2 years ago • 3 comments

Feature description

Currently we obtain something like:

Unable to decode request body: Error decoding JSON stream for type [res]: Error decoding property [<some class> property1] of type [class <some class>]: Error decoding property [<some other class> property1] of type [class <some other class>]: Unexpected token VALUE_STRING, expected START_OBJECT

We wanted to be able to customize something like:

Invalid json for <fieldName> for class <class name>

driverpt avatar Aug 18 '23 13:08 driverpt

You can customize the error handling https://docs.micronaut.io/latest/guide/index.html#errorHandling

yawkat avatar Aug 18 '23 13:08 yawkat

Is it possible to add the Target Class to the Exception?

driverpt avatar Aug 22 '23 21:08 driverpt

atm the type is part of the message but not exposed as a field on the SerdeException. we could add a subtype that makes this accessible.

yawkat avatar Aug 23 '23 06:08 yawkat