Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement user friendly exceptions #49

Open
buremba opened this issue Apr 13, 2020 · 2 comments
Open

Implement user friendly exceptions #49

buremba opened this issue Apr 13, 2020 · 2 comments

Comments

@buremba
Copy link

buremba commented Apr 13, 2020

It would be nice if we could generate user-friendly exceptions from JacksonMappingExceptions. 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.

@buremba
Copy link
Author

buremba commented Apr 13, 2020

I realized that I actually created a relevant thread in Google Groups 2.5 years ago. :) Here is the link:

https://groups.google.com/forum/#!searchin/jackson-user/user$20friendly%7Csort:date/jackson-user/uANVNXoi9HI/46YVwrBUAgAJ

I still think that it would be great if Jackson would support it out of the box.

@cowtowncoder
Copy link
Member

In general I am definitely +1 for improved exception messages.
One major caveat here is that there is no central point with enough information so in many cases improvements need to be made for specific subset of failure cases. On plus side, more and more information is now available via context so that JSONPointer compatible notation can be created (and is in fact produced for many exceptions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants