Skip to content

Instantly share code, notes, and snippets.

@propensive
Created November 25, 2014 14:04
Show Gist options
  • Save propensive/7756a19358b51774d215 to your computer and use it in GitHub Desktop.
Save propensive/7756a19358b51774d215 to your computer and use it in GitHub Desktop.
Better compile-time diagnostics when attempting to extract case classes from JSON
scala> case class Bar(file: java.io.File) // We can't extract a File
defined class Bar
scala> case class Foo(bar: Bar) // therefore we can't extract a Bar
defined class Foo
scala> json""{ "bar": { "file": "..." } }""".as[Foo]
Could not generate a Json extractor for case class Bar because a Json extractor for parameter `file' of type java.io.File could not be found
Could not generate a Json extractor for case class Foo because a Json extractor for parameter `bar' of type Bar could not be found
<console>:21: error: cannot extract type Foo from rapture.json.Json.
json"""{ "bar": { "file": "..." } }""".as[Foo]
^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment