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

Add new exception type InputCoercionException to be used for failed coercions like overflow for int #508

Closed
cowtowncoder opened this issue Jan 16, 2019 · 1 comment
Milestone

Comments

@cowtowncoder
Copy link
Member

Currently problems like overflow for numeric type (when JSON number value exceeds range of requested target type like int) simply use JsonParseException to indicate the problem (both at streaming and databind level).

But it would be better if we could use more targeted exception, to let calling application potentially handle problems differently. We can also add some metadata about type of failure, such as initial token type and expected target type.
It is also true that coercion failures -- where we start from valid JSON value, but fail to convert into desired target type -- are not parse (decode) problems at all, but rather mismatch problems.

So let's add something like InputCoercionException, which extends JsonProcessingException, but not JsonParseException.

With 3.x we may want to tackle other problems: for example, lack of context for "lower level" JsonProcessingExceptions (compared to JsonMappingException)

@cowtowncoder cowtowncoder changed the title Add new exception type to be used for failed coercions like overflow for int Add new exception type InputCoercionException to be used for failed coercions like overflow for int Jan 16, 2019
@cowtowncoder
Copy link
Member Author

Also: to still allow catching "all reader-side streaming exception", add intermediate StreamReadException.

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

1 participant