notificationRepository->find($message->getNotificationId()); $addressee = $this->userRepository->find($message->getAddresseeId()); if (null === $notification) { $this->logger->error('[SendImmediateNotificationEmailHandler] Notification not found', [ 'notification_id' => $message->getNotificationId(), ]); throw new \InvalidArgumentException(sprintf('Notification with ID %s not found', $message->getNotificationId())); } if (null === $addressee) { $this->logger->error('[SendImmediateNotificationEmailHandler] Addressee not found', [ 'addressee_id' => $message->getAddresseeId(), ]); throw new \InvalidArgumentException(sprintf('User with ID %s not found', $message->getAddresseeId())); } try { $this->notificationMailer->sendEmailToAddressee($notification, $addressee); } catch (\Exception $e) { $this->logger->error('[SendImmediateNotificationEmailHandler] Failed to send email', [ 'notification_id' => $message->getNotificationId(), 'addressee_id' => $message->getAddresseeId(), 'stacktrace' => $e->getTraceAsString(), ]); throw $e; } } }