From 1b9236ba3f5ec54adb7446f97de839a0554041d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 5 Sep 2023 11:48:23 +0200 Subject: [PATCH] Improve VCS error when creating repository --- src/Appwrite/Auth/OAuth2/Exception.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Auth/OAuth2/Exception.php b/src/Appwrite/Auth/OAuth2/Exception.php index 28d8d652f9..c3b574fb71 100644 --- a/src/Appwrite/Auth/OAuth2/Exception.php +++ b/src/Appwrite/Auth/OAuth2/Exception.php @@ -17,14 +17,17 @@ class Exception extends AppwriteException $decoded = json_decode($response, true); if (\is_array($decoded)) { if (\is_array($decoded['error'] ?? '')) { - $this->error = $decoded['error']['status']; - $this->errorDescription = $decoded['error']['message']; - $this->message = $this->error . ': ' . $this->errorDescription; + $this->error = $decoded['error']['status'] ?? 'Unknown error'; + $this->errorDescription = $decoded['error']['message'] ?? 'No description'; + } else if (\is_array($decoded['errors'] ?? '')) { + $this->error = $decoded['error'] ?? $decoded['message'] ?? 'Unknown error'; + $this->errorDescription = $decoded['errors'][0]['message'] ?? 'No description'; } else { $this->error = $decoded['error'] ?? $decoded['message'] ?? 'Unknown error'; $this->errorDescription = $decoded['error_description'] ?? 'No description'; - $this->message = $this->error . ': ' . $this->errorDescription; } + + $this->message = $this->error . ': ' . $this->errorDescription; } $type = match ($code) { 400 => AppwriteException::USER_OAUTH2_BAD_REQUEST,