Catch exception during cron execution and log to debug

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2019-12-19 20:10:32 +01:00
committed by Backportbot
parent 12fb5f0a1f
commit 9550c2eb2f
3 changed files with 23 additions and 4 deletions

View File

@@ -27,6 +27,8 @@ use OC\BackgroundJob\Job;
use OCA\Deck\Db\Card;
use OCA\Deck\Db\CardMapper;
use OCA\Deck\Notification\NotificationHelper;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\ILogger;
class ScheduledNotifications extends Job {
@@ -34,13 +36,17 @@ class ScheduledNotifications extends Job {
protected $cardMapper;
/** @var NotificationHelper */
protected $notificationHelper;
/** @var ILogger */
protected $logger;
public function __construct(
CardMapper $cardMapper,
NotificationHelper $notificationHelper
NotificationHelper $notificationHelper,
ILogger $logger
) {
$this->cardMapper = $cardMapper;
$this->notificationHelper = $notificationHelper;
$this->logger = $logger;
}
/**
@@ -52,8 +58,13 @@ class ScheduledNotifications extends Job {
$cards = $this->cardMapper->findOverdue();
/** @var Card $card */
foreach ($cards as $card) {
$this->notificationHelper->sendCardDuedate($card);
try {
$this->notificationHelper->sendCardDuedate($card);
} catch (DoesNotExistException $e) {
// Skip if any error occurs
$this->logger->debug('Could not create overdue notification for card with id ' . $card->getId());
}
}
}
}
}