Skip to content

Be more specific about plugin exceptions #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions plugins/build-your-own.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Like in case of the ``$next`` callable, you must pass the ``$request`` as the fi
or you will end up in an infinite execution loop.

The ``$next`` and ``$first`` callables will return a :doc:`/components/promise`.
You can manipulate the ``ResponseInterface`` or the ``Exception`` by using the
You can manipulate the ``Psr\Http\Message\ResponseInterface`` or the ``Http\Client\Exception`` by using the
``then`` method of the promise::

public function handleRequest(RequestInterface $request, callable $next, callable $first)
Expand All @@ -76,7 +76,7 @@ You can manipulate the ``ResponseInterface`` or the ``Exception`` by using the

return $next($request)->then(function (ResponseInterface $response) {
return $response->withHeader('MyResponseHeader', 'value');
}, function (Exception $exception) {
}, function (\Http\Client\Exception $exception) {
echo $exception->getMessage();

throw $exception;
Expand All @@ -89,6 +89,11 @@ You can manipulate the ``ResponseInterface`` or the ``Exception`` by using the
PSR_ is released. Once it is out, we will use this PSR in HTTPlug and
deprecate the old contract.

.. warning::

If a plugin throws an exception that does not implement ``Http\Client\Exception``
it will break the plugin chain.

To better understand the whole process check existing implementations in the
`client-common package`_.

Expand Down