O'Reilly logo

RESTful Web Services with Scala by Jos Dirksen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Request validation and custom responses

So far, we haven't looked at what happens when one of our RequestReaders can't read the required information. A header might be missing, a parameter might be in the incorrect format, or a cookie isn't present. If, for instance, you rename some fields in the JSON for the Step 03 – Create Task request, and make the request, it will fail silently:

Request validation and custom responses

Finch, however, provides an elegant way to handle all the exceptions from the RequestReaders. First, we'll look at the result we'll be aiming for. First, start another sbt project like this:

$ sbt runCH02-runCH02Step4
[info] Loading project definition from /Users/jos/dev/git/rest-with-scala/project ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required