{"action":"created","issue":{"url":"https://api.github.com/repos/calcinai/xero-php/issues/61","labels_url":"https://api.github.com/repos/calcinai/xero-php/issues/61/labels{/name}","comments_url":"https://api.github.com/repos/calcinai/xero-php/issues/61/comments","events_url":"https://api.github.com/repos/calcinai/xero-php/issues/61/events","html_url":"https://github.com/calcinai/xero-php/issues/61","id":97454327,"number":61,"title":"How i can handle exception from my laravel model file?","user":{"login":"jaytasol","id":13366421,"avatar_url":"https://avatars.githubusercontent.com/u/13366421?v=3","gravatar_id":"","url":"https://api.github.com/users/jaytasol","html_url":"https://github.com/jaytasol","followers_url":"https://api.github.com/users/jaytasol/followers","following_url":"https://api.github.com/users/jaytasol/following{/other_user}","gists_url":"https://api.github.com/users/jaytasol/gists{/gist_id}","starred_url":"https://api.github.com/users/jaytasol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaytasol/subscriptions","organizations_url":"https://api.github.com/users/jaytasol/orgs","repos_url":"https://api.github.com/users/jaytasol/repos","events_url":"https://api.github.com/users/jaytasol/events{/privacy}","received_events_url":"https://api.github.com/users/jaytasol/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-07-27T12:41:45Z","updated_at":"2015-07-29T07:38:07Z","closed_at":null,"body":"Hi, \r\n\r\nI am using this example in my model file vendor/calcinai/xero-php/examples/public.php and i am using database instead of session to store tokens and token_secret. \r\n\r\nAnd i am using bellow code to import invoices to store in database also same time i am importing contacts info for particular invoices. \r\n\r\n $invoices=$this->xero->load('Accounting\\\\Invoice')->where('Status==\"AUTHORISED\" OR Status==\"PAID\"')->modifiedAfter(new \\DateTime($this->timesince))->execute();\r\n\r\nNow there are many invoices so some time token become expired during process and at that time i want to through exception and want to store error in my log file. \r\n\r\nBut when i try that, it can not be handled. so then i used directly send function like below code but then also it can not be halalled as it terminate script in parse function of response .php file.  \r\n\r\n\r\n     $url = new URL($xero, \\XeroPHP\\Models\\Accounting\\Invoice::getResourceURI());\r\n     $request = new Request($xero, $url, Request::METHOD_GET);\r\n     $request->setParameter('where', $where);\r\n      try {\r\n            $request->send();\r\n        } catch (Exception $e){\r\n            echo($e->getCode());\r\n            print_r($request->getResponse()->getOAuthResponse());\r\n        }\r\n\r\nSo i want to know how can i handle exception when i got some error like token expired etc... \r\nIs there any way that i can handle it with this? \r\n\r\n$invoices=$this->xero->load('Accounting\\\\Invoice')->where('Status==\"AUTHORISED\" OR Status==\"PAID\"')->modifiedAfter(new \\DateTime($this->timesince))->execute();\r\n\r\nThanks,\r\nJay"},"comment":{"url":"https://api.github.com/repos/calcinai/xero-php/issues/comments/125870617","html_url":"https://github.com/calcinai/xero-php/issues/61#issuecomment-125870617","issue_url":"https://api.github.com/repos/calcinai/xero-php/issues/61","id":125870617,"user":{"login":"mhlavac","id":743421,"avatar_url":"https://avatars.githubusercontent.com/u/743421?v=3","gravatar_id":"","url":"https://api.github.com/users/mhlavac","html_url":"https://github.com/mhlavac","followers_url":"https://api.github.com/users/mhlavac/followers","following_url":"https://api.github.com/users/mhlavac/following{/other_user}","gists_url":"https://api.github.com/users/mhlavac/gists{/gist_id}","starred_url":"https://api.github.com/users/mhlavac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhlavac/subscriptions","organizations_url":"https://api.github.com/users/mhlavac/orgs","repos_url":"https://api.github.com/users/mhlavac/repos","events_url":"https://api.github.com/users/mhlavac/events{/privacy}","received_events_url":"https://api.github.com/users/mhlavac/received_events","type":"User","site_admin":false},"created_at":"2015-07-29T07:38:07Z","updated_at":"2015-07-29T07:38:07Z","body":"@jaytasol it catches all Exceptions in the try,catch block. If you want to catch XeroPHP\\Exception only then you have to use whole namespace, or add use. Keep in mind that if you need to catch PHP Exception and you add use XeroPHP\\Exception, then you will have to catch PHP Exception with root namespace `\\Exception`"}}