File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -300,6 +300,29 @@ $client->nextPage($response["pages"]);
300300```
301301
302302
303+ ## Exceptions
304+
305+ Exceptions are handled by [ Guzzle] ( https://github.com/guzzle/guzzle ) .
306+ The Intercom API may return an unsuccessful HTTP response, for example when a resource is not found (404).
307+ If you want to catch errors you can wrap your API call into a try/catch:
308+
309+ ``` php
310+ use GuzzleHttp\Exception\ClientException;
311+
312+ try {
313+ $user = $client->users->getUser("570680a8a1bcbca8a90001b9");
314+ } catch(ClientException $e) {
315+ $response = $e->getResponse();
316+ $statusCode = $response->getStatusCode();
317+ if ($statusCode == '404') {
318+ // Handle 404 error
319+ return;
320+ } else {
321+ throw $e;
322+ }
323+ }
324+ ```
325+
303326## Pull Requests
304327
305328- ** Add tests!** Your patch won't be accepted if it doesn't have tests.
You can’t perform that action at this time.
0 commit comments