finagle/finch

Better errors for missing/wrong JSON properties

開放

#264 建立於 2015年5月6日

 (3 則留言) (1 個反應) (1 位負責人)Scala (218 個分叉)batch import
featurehacktoberfestready

倉庫指標

星標
 (1,594 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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.

貢獻者指南