Skip to content

Commit a963eed

Browse files
authored
Merge pull request #1785 from sivaschenko/exception-handling
[Refactoring] Improved exception handling
2 parents 13c22e1 + 46dcdf6 commit a963eed

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

AdobeStockClient/Model/ConnectionWrapper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ private function handleException(\Exception $exception, string $message): \Excep
132132
$this->flushUserTokens->execute();
133133
return new AuthorizationException(__('Adobe API login has expired!'));
134134
}
135+
if (strpos($exception->getMessage(), 'Could not validate the oauth token') !== false) {
136+
$this->flushUserTokens->execute();
137+
return new AuthorizationException(__('Adobe API login has expired!'));
138+
}
135139
$phrase = __(
136140
$message . ': %error_message',
137141
['error_message' => $exception->getMessage()]

AdobeStockImageAdminUi/Controller/Adminhtml/License/GetList.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\App\Action\HttpGetActionInterface;
1313
use Magento\Framework\Controller\Result\Json;
1414
use Magento\Framework\Controller\ResultFactory;
15+
use Magento\Framework\Exception\LocalizedException;
1516
use Psr\Log\LoggerInterface;
1617

1718
/**
@@ -72,6 +73,12 @@ public function execute()
7273
'success' => true,
7374
'result' => $result
7475
];
76+
} catch (LocalizedException $exception) {
77+
$responseCode = self::HTTP_INTERNAL_ERROR;
78+
$responseContent = [
79+
'success' => false,
80+
'message' => $exception->getMessage()
81+
];
7582
} catch (\Exception $exception) {
7683
$this->logger->critical($exception);
7784
$responseCode = self::HTTP_INTERNAL_ERROR;

0 commit comments

Comments
 (0)