Skip to content

Commit

Permalink
PISHPS-374: extended logging of OrderStateService (#879)
Browse files Browse the repository at this point in the history
* PISHPS-374: extended logging of OrderStateService

* PISHPS-374: extended logging of DeliveryTransitionService and TransactionTransitionService

* PISHPS-374: catching throwable instead of base exception

* PISHPS-374: csfix
  • Loading branch information
m-muxfeld-diw authored Oct 25, 2024
1 parent 4798690 commit e0adf92
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/Service/Order/OrderStateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Kiener\MolliePayments\Service\Order;

use Exception;
use Kiener\MolliePayments\Service\Transition\OrderTransitionServiceInterface;
use Kiener\MolliePayments\Setting\MollieSettingStruct;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -72,11 +71,16 @@ public function setOrderState(OrderEntity $order, string $orderState, Context $c
}

return true;
} catch (Exception $e) {
} catch (\Throwable $e) {
$this->logger->error(
$e->getMessage(),
[
'function' => 'payment-automate-order-state',
'order.id' => $order->getId(),
'order.number' => $order->getOrderNumber(),
'new.state' => $orderState,
'old.state' => $currentStatus,
'trace' => $e->getTraceAsString(),
]
);
}
Expand Down
22 changes: 21 additions & 1 deletion src/Service/Transition/DeliveryTransitionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,27 @@ private function getAvailableTransitions(OrderDeliveryEntity $delivery, Context
*/
private function performTransition(OrderDeliveryEntity $delivery, string $transitionName, Context $context): void
{
$this->transitionService->performTransition(OrderDeliveryDefinition::ENTITY_NAME, $delivery->getId(), $transitionName, $context);
$this->loggerService->debug(
sprintf(
'Performing transition %s for delivery %s',
$transitionName,
$delivery->getId()
)
);

try {
$this->transitionService->performTransition(OrderDeliveryDefinition::ENTITY_NAME, $delivery->getId(), $transitionName, $context);
} catch (\Throwable $e) {
$this->loggerService->error(
$e->getMessage(),
[
'method' => 'delivery-transition-perform-transition',
'delivery.id' => $delivery->getId(),
'delivery.payload' => $delivery->jsonSerialize(),
'transition' => $transitionName
]
);
}
}

/**
Expand Down
20 changes: 19 additions & 1 deletion src/Service/Transition/TransactionTransitionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,24 @@ private function getAvailableTransitions(string $entityId, Context $context): ar

private function performTransition(string $entityId, string $transitionName, Context $context): void
{
$this->transitionService->performTransition(OrderTransactionDefinition::ENTITY_NAME, $entityId, $transitionName, $context);
$this->logger->debug(
sprintf(
'Performing transition %s for order transaction %s',
$transitionName,
$entityId
)
);
try {
$this->transitionService->performTransition(OrderTransactionDefinition::ENTITY_NAME, $entityId, $transitionName, $context);
} catch (\Throwable $e) {
$this->logger->error(
$e->getMessage(),
[
'method' => 'transaction-transition-service-perform-transition',
'entity.id' => $entityId,
'transition' => $transitionName
]
);
}
}
}

0 comments on commit e0adf92

Please sign in to comment.