Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2021-08-09 16:18:45 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-08-09 16:18:45 +0300
commitaaf8c108dc90972fa651e0cd9f7635b3c9d3a929 (patch)
treed0290c56082eeafea6be14ff6bfe44f7ab1cfd42 /lib/Command
parentc3957214312c1ab1c74734c6500a42190e264800 (diff)
Handle account not found for CLI sync
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/Command')
-rw-r--r--lib/Command/SyncAccount.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Command/SyncAccount.php b/lib/Command/SyncAccount.php
index 5bdcd84b4..8f2e8baa6 100644
--- a/lib/Command/SyncAccount.php
+++ b/lib/Command/SyncAccount.php
@@ -32,6 +32,7 @@ use OCA\Mail\IMAP\MailboxSync;
use OCA\Mail\Service\AccountService;
use OCA\Mail\Service\Sync\ImapToDbSynchronizer;
use OCA\Mail\Support\ConsoleLoggerDecorator;
+use OCP\AppFramework\Db\DoesNotExistException;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
@@ -82,7 +83,13 @@ class SyncAccount extends Command {
$accountId = (int)$input->getArgument(self::ARGUMENT_ACCOUNT_ID);
$force = $input->getOption(self::OPTION_FORCE);
- $account = $this->accountService->findById($accountId);
+ try {
+ $account = $this->accountService->findById($accountId);
+ } catch (DoesNotExistException $e) {
+ $output->writeln("<error>Account $accountId does not exist</error>");
+
+ return 1;
+ }
$this->sync($account, $force, $output);