Skip to content

Document exceptions #71

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 2 commits into from
Mar 2, 2016
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions components/promise.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,8 @@ executed if the request results in an error::
}
);

The ``$exception`` of the failure callback SHOULD implement ``Http\Client\Exception``.
See :doc:`../httplug/exceptions` for more information on the exception classes you might encounter.

.. _`Promise PSR`: https://groups.google.com/forum/?fromgroups#!topic/php-fig/wzQWpLvNSjs
.. _Promises/A+: https://promisesaplus.com
26 changes: 26 additions & 0 deletions httplug/exceptions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Exceptions
==========

HTTPlug defines a common interface for all exceptions thrown by HTTPlug implementations.
Every exception thrown by a HTTP client must implement ``Http\Client\Exception``.

``HttpClient::sendRequest()`` can throw one of the following exceptions.

================================== ============================= ===================
Exception Thrown when Methods available
================================== ============================= ===================
TransferException something unexpected happened -
└ RequestException the request is invalid ``getRequest()``
|nbsp| |nbsp| └ NetworkException no response received
due to network issues ``getRequest()``
|nbsp| |nbsp| └ HttpException error response ``getRequest()``
``getResponse()``
================================== ============================= ===================

.. note::

The ``sendAsyncRequest`` should never throw an exception but always return a
:doc:`../components/promise`. The exception classes used in ``Promise::wait`` and the ``then``
callback are however the same as explained here.

.. |nbsp| unicode:: U+00A0 .. non-breaking space
1 change: 1 addition & 0 deletions httplug/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ HTTPlug defines two HTTP client interfaces that we kept as simple as possible:

* ``HttpAsyncClient`` defines a ``sendAsyncRequest`` method that sends a request
asynchronously and always returns a ``Http\Client\Promise``.
See :doc:`../components/promise` for more information.

Implementations
---------------
Expand Down
1 change: 1 addition & 0 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ for discussion around a future HTTP client PSR.

Introduction <httplug/introduction>
Usage <httplug/usage>
Exceptions <httplug/exceptions>
Tutorial <httplug/tutorial>
Migrating <httplug/migrating>

Expand Down