pekko/akka-docs/rst/scala/http/routing-dsl/directives/future-directives/completeOrRecoverWith.rst
2016-01-14 00:31:03 +01:00

25 lines
907 B
ReStructuredText

.. _-completeOrRecoverWith-:
completeOrRecoverWith
=====================
Signature
---------
.. includecode2:: /../../akka-http/src/main/scala/akka/http/scaladsl/server/directives/FutureDirectives.scala
:snippet: completeOrRecoverWith
Description
-----------
If the ``Future[T]`` succeeds the request is completed using the value's marshaller (this directive therefore
requires a marshaller for the future's parameter type to be implicitly available). The execution of the inner
route passed to this directive is only executed if the given future completed with a failure,
exposing the reason of failure as a extraction of type ``Throwable``.
To handle the successful case manually as well, use the :ref:`-onComplete-` directive, instead.
Example
-------
.. includecode2:: ../../../../code/docs/http/scaladsl/server/directives/FutureDirectivesExamplesSpec.scala
:snippet: completeOrRecoverWith