From 20c44371c9d5bb01a406915310fe9b728b84eebb Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Sat, 30 May 2015 08:29:40 +0300 Subject: [PATCH] Some exception handling. More output in verbose mode. --- .../Command/UpdateSubscriptionsCommand.php | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/Skobkin/Bundle/PointToolsBundle/Command/UpdateSubscriptionsCommand.php b/src/Skobkin/Bundle/PointToolsBundle/Command/UpdateSubscriptionsCommand.php index 7052c6c..fcb505d 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Command/UpdateSubscriptionsCommand.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Command/UpdateSubscriptionsCommand.php @@ -39,16 +39,45 @@ class UpdateSubscriptionsCommand extends ContainerAwareCommand if (!$serviceUser) { // @todo Retrieving user + return false; } - $serviceSubscribers = $api->getUserSubscribersByLogin($serviceUserName); + if ($output->isVerbose()) { + $output->writeln('Getting service subscribers'); + } + + try { + $serviceSubscribers = $api->getUserSubscribersByLogin($serviceUserName); + } catch (\Exception $e) { + $output->writeln('Error while getting service subscribers'); + return false; + } + + if ($output->isVerbose()) { + $output->writeln('Updating service subscribers'); + } // Updating service subscribers $subscriptionsManager->updateUserSubscribers($serviceUser, $serviceSubscribers); + if ($output->isVerbose()) { + $output->writeln('Processing service subscribers'); + } + // Updating service users subscribers foreach ($serviceSubscribers as $user) { - $userCurrentSubscribers = $api->getUserSubscribersByLogin($user->getLogin()); + $output->writeln(' Processing @' . $user->getLogin()); + + try { + $userCurrentSubscribers = $api->getUserSubscribersByLogin($user->getLogin()); + } catch (\Exception $e) { + $output->writeln(' Error while getting subscribers. Skipping.'); + continue; + } + + if ($output->isVerbose()) { + $output->writeln(' Updating service subscribers'); + } $subscriptionsManager->updateUserSubscribers($user, $userCurrentSubscribers);