From 47e592873849f91e0f5b294975f7cf54d3cee501 Mon Sep 17 00:00:00 2001 From: patrick Date: Sun, 30 Jun 2019 22:34:16 +1000 Subject: [PATCH] catch ratelimit exception but not tested --- Xero.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Xero.php b/Xero.php index 56f3aa2..731293a 100644 --- a/Xero.php +++ b/Xero.php @@ -2,6 +2,8 @@ namespace Biukop; use \XeroPHP\Application\PrivateApplication; +use \XeroPHP\Remote\Exception\RateLimitExceededException; + class Xero { private $xero; private $clientgroup="48646f3d-cf5e-4fea-8c8b-5812bd540e1b"; @@ -70,8 +72,13 @@ class Xero { //sync users to wordpress system //does not work for too many users or employees public function sync_users(){ - $this->sync_clients(); - $this->sync_employees(); + try{ + $this->sync_clients(); + $this->sync_employees(); + }catch(RateLimitExceededException $e){ + $msg= "Xero API rate limit exceeded, please try again later, existing sync within 600 seconds will by passed automatically\n"; + $this->logConsole($msg); + } } private function sync_clients(){ $contacts = $this->getClients($this->clientgroup);