Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added documentation for catching validation exceptions
  • Loading branch information
bkuhl committed May 13, 2019
1 parent d24f68b commit b86be9d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Expand Up @@ -25,6 +25,7 @@ This is the official Help Scout PHP client. This client contains methods for eas
* [Webhooks](#webhooks)
* [Workflows](#workflows)
* [Error Handling](#error-handling)
* [Validation](#validation)
* [Pagination](#pagination)
* [Testing](#testing)

Expand Down Expand Up @@ -822,6 +823,29 @@ $client->workflows()->updateStatus($id, 'active');

Any exception thrown by the client directly will implement `HelpScout\Api\Exception` and HTTP errors will result in `Http\Client\Exception\RequestException` being thrown.

### Validation

You'll encounter a `ValidationErrorException` if there are any validation errors with the request you submitted to the API. Here's a quick example on how to use that exception:

```php
try {
// do something
} catch (\HelpScout\Api\Exception\ValidationErrorException $e) {
$error = $e->getError();

var_dump(
// A reference id for that request. Including this anytime you contact Help Scout support will enable
// us to help you much more quickly
$error->getLogRef(),

// Details about the invalid fields in the request
$error->getErrors()
);
exit;
}
```


## Pagination

When fetching a collection of entities the client will return an instance of `HelpScout\Api\Entity\Collection`. If the end point supports pagination then it will return an instance of `HelpScout\Api\Entity\PagedCollection`.
Expand Down
3 changes: 3 additions & 0 deletions src/Http/Hal/VndError.php
Expand Up @@ -47,6 +47,9 @@ public function getMessage(): string
}

/**
* If populated, include this in any support requests you submit to HelpScout which will help us identify
* any issues you encounter.
*
* @return string|null
*/
public function getLogRef()
Expand Down

0 comments on commit b86be9d

Please sign in to comment.