finagle / finagle/finch

Better errors for missing/wrong JSON properties

Open
#264 3 comments 1 reaction 1 assignee Claimed by @vkostyukov View on GitHub
feature hacktoberfest ready
Dominant language
Scala
Stars
1.6k
Forks
217
PR merge metrics
No merged PRs in 30d

Description

It would be nice if we could better understand what's wrong with an incoming JSON body and throw a reasonable error about it. For now, we throw `NotParsed(BodyItem, ....)`. Would be nice if we could promote `BodyItem` to a case class `BodyItem(name: String)` and wrap missing/wrongly decoded properties in it.

This is only about the cases when JSON is decoded directly to a case class: `body.as[User]`. I believe, end users should handle this manually (with custom exceptions like `NotFoundJsonProperty`) when dealing with raw JSON types directly: `body.as[Json]` and then parsing them with AST API provided by a JSON library.

See discussion in #261 started by @lderks.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.