Change record status: 
Project: 
Introduced in branch: 
9.2.x
Introduced in version: 
9.2.0-alpha1
Description: 

Drupal 9 uses Guzzle 6 for sending HTTP requests. Drupal 10 will use Guzzle 7.

Both Guzzle\Exception\RequestException and Guzzle\Exception\ConnectException exist in both Guzzle 6 and 7. However, in Guzzle 6, ConnectException extends RequestException, whereas in Guzzle 7 they are siblings that implement different interfaces. Both exceptions extend TransferException.

In order to make Drupal 9's code forward-compatible with Guzzle 7, Drupal core now typically catches Guzzle\Exception\TransferException instead of Guzzle\Exception\RequestException when handling request errors. This handles both cases where the request is successful but there is an error condition for the response, and cases where the request cannot be completed due to network issues.

Code that depends on the value of the response should handle ConnectException and RequestException separately for forward-compatibility with Guzzle 7, because when ConnectException is returned, there is no response and in Guzzle 7 methods related to the response are removed.