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()
    β”” NetworkException no response received due to network issues getRequest()
    β”” HttpException error response getRequest() getResponse()

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.