=doc add custom ValidationRejection handling to samples

This commit is contained in:
2beaucoup 2015-12-21 15:19:38 +01:00
parent dcfa56e547
commit 565b480b2e
2 changed files with 10 additions and 1 deletions

View file

@ -25,6 +25,9 @@ object MyRejectionHandler {
.handle { case AuthorizationFailedRejection
complete((Forbidden, "You're out of your depth!"))
}
.handle { case ValidationRejection(msg, _)
complete((InternalServerError, "That wasn't valid! " + msg))
}
.handleAll[MethodRejection] { methodRejections
val names = methodRejections.map(_.supported.name)
complete((MethodNotAllowed, s"Can't do that! Supported: ${names mkString " or "}!"))