- //Catch exception
- } catch(\Google\Service\Exception $e) {
- //Throw error
- throw new \LogicException('Calendar list failed', 0, $e);
+
+ //Cache calendars
+ return $calendars;
+ }
+ );
+ //Catch exception
+ } catch(\Google\Service\Exception $e) {
+ //With 401 code
+ if ($e->getCode() == 401) {
+ //Add error in flash message
+ $this->addFlash(
+ 'error',
+ $this->translator->trans(
+ 'Unable to list calendars: %error%',
+ ['%error%' => $e->getMessage()]
+ )
+ );
+
+ //Iterate on each google token calendars
+ foreach($googleToken->getGoogleCalendars() as $googleCalendar) {
+ //Remove google token calendar
+ $this->manager->remove($googleCalendar);