FasterXML / FasterXML/jackson-future-ideas

Implement user friendly exceptions

Aperta
#49 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Nessun dato sulla lingua
Stelle
21
Fork
3
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

It would be nice if we could generate user-friendly exceptions from `JacksonMappingException`s. Here is an example exception:

```
com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException: Instantiation of [simple type, class io.rakam.ui.service.recipe.Recipe$ExportDashboard] value failed for JSON property name due to missing (therefore NULL) value for creator parameter name which is a non-nullable type
at [Source: (String)"{"fname":"Events Overview","category":"Segment Events","filterSchema":[{"name":"dateRange","type":"mappingDimension","value":{"name":"eventTimestamp"},"defaultValue":"P5Y","isRequired":true}],"reports":[{"name":"Events by Last Seen App Version","ttl":"PT1H","x":0,"y":3,"h":2,"w":6,"component":"r-segmentation-table","type":1,"reportOptions":{"modelName":"segment_events","dimensions":[{"name":"event_text","modelName":"segment_events","relationName":null,"postOperation":null}],"measures":[{"name":""[truncated 2664 chars]; line: 1, column: 3164] (through reference chain: io.rakam.ui.service.recipe.Recipe$ExportDashboard["name"])
```

Something like the following message that includes JsonPath would be much more helpful to the users:
```
Parameter .name is required.
```

We're currently doing this in our web application but since the data mappers have their own exceptions, we need to handle many different cases. It might be a good practice if `JsonMappingException` could have a method such as `getUserFriendlyMessage` that allows developers to do it in data-mappers.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.