8000 [Docs] Update namespace for error objects · CodingSeo/laravel-json-api@f0f9ec6 · GitHub
[go: up one dir, main page]

Skip to content

Commit f0f9ec6

Browse files
committed
[Docs] Update namespace for error objects
Closes cloudcreativity#526
1 parent 93bffca commit f0f9ec6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

docs/features/errors.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ the package's error class. All the keys described in the specification's
1818
For example:
1919

2020
```php
21-
use CloudCreativity\LaravelJsonApi\Document\Error;
21+
use CloudCreativity\LaravelJsonApi\Document\Error\Error;
2222

23-
$error = Error::create([
23+
$error = Error::fromArray([
2424
'id' => '91053382-7c00-45eb-bdcc-8359d03debbb',
2525
'status' => '500',
2626
'code' => 'unexpected',
@@ -40,15 +40,16 @@ The `JsonApiController` has a responses factory that can create error responses.
4040
to return an error response in a controller hook, as demonstrated in the following example:
4141

4242
```php
43-
use CloudCreativity\LaravelJsonApi\Document\Error;
43+
use CloudCreativity\LaravelJsonApi\Document\Error\Error;
44+
use CloudCreativity\LaravelJsonApi\Http\Controllers\JsonApiController;
4445

4546
class PaymentController extends JsonApiController
4647
{
4748

4849
protected function creating()
4950
{
5051
if (/** some condition */) {
51-
return $this->reply()->errors(Error::create([
52+
return $this->reply()->errors(Error::fromArray([
5253
'title' => 'Payment Required',
5354
'detail' => 'Your card has expired.',
5455
'status' => '402',
@@ -85,12 +86,12 @@ to a JSON API response. For example:
8586

8687
```php
8788
use Neomerx\JsonApi\Exceptions\JsonApiException;
88-
use CloudCreativity\LaravelJsonApi\Document\Error;
89+
use CloudCreativity\LaravelJsonApi\Document\Error\Error;
8990

9091
try {
9192
dispatchNow(new ChargeCard($token));
9293
} catch (\App\PaymentException $ex) {
93-
$error = Error::create([
94+
$error = Error::fromArray([
9495
'title' => 'Payment Required',
9596
'detail' => $ex->getMessage(),
9697
'status' => '402',

0 commit comments

Comments
 (0)
0