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

Exception handling and rejections

In this section, we'll look at how Akka HTTP handles exceptions and rejections. Before we look at the code, we'll once again use Postman to show what we want to accomplish. Let's start with how rejections are handled. Rejections are functional errors that are either thrown by directives or which you can throw yourself. In this example, we add some validations to the create task request. So run sbt runCH05-runCH05Step3, open up Postman, and execute the request, Step 03 - Rejection handling:

Exception handling and rejections

As you can see from the response, the title of the task we want to create must be at least 10 characters. The code where we add ...

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