Skip to content

Commit

Permalink
Improve exception logging (#37)
Browse files Browse the repository at this point in the history
Fix #23 PW-2747
  • Loading branch information
Rune Laenen authored Aug 13, 2020
1 parent c61c8ad commit 43093d1
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
8 changes: 7 additions & 1 deletion Components/Adyen/PaymentMethodService.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ public function getPaymentMethods(
try {
$paymentMethods = $checkout->paymentMethods($requestParams);
} catch (AdyenException $e) {
$this->logger->critical($e);
$this->logger->critical('Adyen Exception', [
'message' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'errorType' => $e->getErrorType(),
'status' => $e->getStatus()
]);
return [];
}

Expand Down
6 changes: 5 additions & 1 deletion Components/NotificationProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ private function process(Notification $notification)
} catch (\Exception $exception) {
$status = NotificationStatus::STATUS_FATAL;
$this->logger->notice('General Exception', [
'exception' => $exception,
'exception' => [
'message' => $exception->getMessage(),
'file' => $exception->getFile(),
'line' => $exception->getLine()
],
'notificationId' => $notification->getId()
]);
yield new NotificationProcessorFeedback(
Expand Down
6 changes: 5 additions & 1 deletion Components/ShopwareVersionCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ public function isHigherThanShopwareVersion(string $shopwareVersion): bool
list($composerVersion, $sha) = explode('@', Versions::getVersion('shopware/shopware'));
$version = $composerVersion;
} catch (OutOfBoundsException $ex) {
$this->logger->error($ex);
$this->logger->error('OutOfBoundsException', [
'message' => $ex->getMessage(),
'file' => $ex->getFile(),
'line' => $ex->getLine()
]);
}
}

Expand Down
11 changes: 8 additions & 3 deletions Controllers/Frontend/Adyen.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,17 @@ public function ajaxDoPaymentAction()
'content' => $paymentInfo
]
));
} catch (\Adyen\AdyenException $e) {
$this->logger->debug($e);
} catch (\Adyen\AdyenException $ex) {
$this->logger->debug('AdyenException during doPayment', [
'message' => $ex->getMessage(),
'file' => $ex->getFile(),
'line' => $ex->getLine()
]);

$this->Response()->setBody(json_encode(
[
'status' => 'error',
'content' => $e->getMessage()
'content' => $ex->getMessage()
]
));
}
Expand Down
8 changes: 6 additions & 2 deletions Subscriber/BackendConfigSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ public function onBackendConfig(\Enlight_Event_EventArgs $args)
) {
try {
$this->originKeysService->generateAndSave();
} catch (AdyenException $e) {
$this->logger->error($e);
} catch (AdyenException $ex) {
$this->logger->error('AdyenException on Backend Config', [
'message' => $ex->getMessage(),
'file' => $ex->getFile(),
'line' => $ex->getLine()
]);
}

if ($this->shopwareVersionCheck->isHigherThanShopwareVersion('v5.5.6')) {
Expand Down

0 comments on commit 43093d1

Please sign in to comment.