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 |
|
└ NetworkException |
no response received due to network issues |
|
└ HttpException |
error response |
|
Note
By default clients will always return a PSR-7 response instead of throwing a HttpException
. Write your
application to check the response status or use the Error Plugin to make sure
the HttpException
is thrown.
Note
The sendAsyncRequest
should never throw an exception but always return a
Promise. The exception classes used in Promise::wait
and the then
callback are however the same as explained here.