Replace GuzzleException by ClientExceptionInterface
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 11 Feb 2021 11:46:54 +0000 (12:46 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 11 Feb 2021 11:46:54 +0000 (12:46 +0100)
ClientExceptionInterface is the standardized Exception and thus preferable.
GuzzleException extends that interface.

wcfsetup/install/files/lib/action/AbstractOauth2Action.class.php
wcfsetup/install/files/lib/action/GithubAuthAction.class.php
wcfsetup/install/files/lib/data/user/avatar/Gravatar.class.php

index c9569871d4eba7d4005d4a89f0ed8497fee9325d..19764d66c92da04e6b4a08c063729d6dca4a69b1 100644 (file)
@@ -3,9 +3,9 @@
 namespace wcf\action;
 
 use GuzzleHttp\ClientInterface;
-use GuzzleHttp\Exception\GuzzleException;
 use GuzzleHttp\Psr7\Request;
 use ParagonIE\ConstantTime\Hex;
+use Psr\Http\Client\ClientExceptionInterface;
 use wcf\system\exception\NamedUserException;
 use wcf\system\exception\PermissionDeniedException;
 use wcf\system\io\HttpFactory;
@@ -148,7 +148,7 @@ abstract class AbstractOauth2Action extends AbstractAction
             // access_token to invalidate 'code'.
             //
             // Validation is happening within the `finally` so that the StateValidationException
-            // overwrites any GuzzleException (improving the error message).
+            // overwrites any HTTP exception (improving the error message).
             if ($this->supportsState()) {
                 $this->validateState();
             }
@@ -229,7 +229,7 @@ abstract class AbstractOauth2Action extends AbstractAction
             $exceptionID = \wcf\functions\exception\logThrowable($e);
 
             $type = 'genericException';
-            if ($e instanceof GuzzleException) {
+            if ($e instanceof ClientExceptionInterface) {
                 $type = 'httpError';
             }
 
index 54268b846c9f2ab7a9910028c072d1c99d4033bc..a8a034e3b1b4224768bf0b6bd422b7c103d3c40d 100644 (file)
@@ -2,8 +2,8 @@
 
 namespace wcf\action;
 
-use GuzzleHttp\Exception\GuzzleException;
 use GuzzleHttp\Psr7\Request;
+use Psr\Http\Client\ClientExceptionInterface;
 use wcf\data\user\User;
 use wcf\form\RegisterForm;
 use wcf\system\exception\NamedUserException;
@@ -162,7 +162,7 @@ final class GithubAuthAction extends AbstractOauth2Action
                         }
                     }
                     $oauthUser["__email"] = $email;
-                } catch (GuzzleException $e) {
+                } catch (ClientExceptionInterface $e) {
                 }
 
                 WCF::getSession()->register('__oauthUser', $oauthUser);
index ae4c92fbc26141e2fbe66ff73c2b8e6d07468347..16f1f8da309259537ef4a2c90990f709e53c0832 100644 (file)
@@ -2,8 +2,8 @@
 
 namespace wcf\data\user\avatar;
 
-use GuzzleHttp\Exception\GuzzleException;
 use GuzzleHttp\Psr7\Request;
+use Psr\Http\Client\ClientExceptionInterface;
 use wcf\system\io\HttpFactory;
 use wcf\system\request\LinkHandler;
 use wcf\system\WCF;
@@ -119,7 +119,7 @@ class Gravatar extends DefaultAvatar
             if ($response->getStatusCode() === 200) {
                 return true;
             }
-        } catch (GuzzleException $e) {
+        } catch (ClientExceptionInterface $e) {
             // Ignore exception, because we return false anyways.
         }