Skip to content

Commit 585b81a

Browse files
committed
Add missing documentation for FilterOptions::THROW_ON_ERROR
1 parent f7ab0e2 commit 585b81a

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,46 @@ $specification = [
369369

370370
The exponent filter spec will call the PHP function `pow()` with the value provided and the result of the filtered `base`
371371

372+
## throwOnError
373+
374+
#### Summary
375+
376+
If true the Filterer will throw any exception caught when filtering a value instead of returning the error in the filter response.
377+
378+
#### Types
379+
380+
* boolean
381+
382+
#### Default
383+
384+
The default value for this option is `false`
385+
386+
#### Constant
387+
388+
```php
389+
TraderInteractive\FilterOptions::THROW_ON_ERROR
390+
```
391+
392+
#### Example
393+
394+
```php
395+
$idFilter = function ($id) : int {
396+
if (!is_int($id)) {
397+
throw new NotFoundException("id '{$id}' was not found");
398+
}
399+
400+
return $id;
401+
};
402+
$specification = [
403+
'id' => [
404+
\TraderInteractive\FilterOptions::THROW_ON_ERROR => true,
405+
[$idFilter],
406+
],
407+
];
408+
```
409+
410+
If the `id` value given in the input is not an integer the Filterer::execute() will throw the `NotFoundException`
411+
372412
### Included Filters
373413
Of course, any function can potentially be used as a filter, but we include some useful filters with aliases for common circumstances.
374414

0 commit comments

Comments
 (0)