Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jenky committed Aug 10, 2023
1 parent 9ed8ca0 commit 99948e0
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,6 @@ public function boot()

## Formatting Exception Response

### Customizing Exception Type

When converting the exception to it's JSON representation, Hades will use the exception class name as the `type`. However, you may customize this behavior by defining a `getType` method on your exception:

```php
<?php

namespace App\Exceptions;

class MissingValueException extends \Exception
{
/**
* Get the exception type.
*
* @return string
*/
public function getType(): string
{
return 'invalid_value';
}
}
```

### Customizing Exception Response

Sometimes you can't control how exception is thrown such as exception from Laravel framework or other third party packages. Laravel 8 introduces [Renderable exception](https://laravel.com/docs/8.x/errors#rendering-exceptions), however you need to build the response manually which might lead to inconsistent error format.
Expand Down Expand Up @@ -215,7 +192,7 @@ To customize this behavior, you may pass the closure to `Hades::forceJsonOutput(
```php
use Illuminate\Http\Request;

Hades::forceJsonOutput(function (Request $request) {
Hades::forceJsonOutput(static function (Request $request) {
return $request->is('api/v1/*');
});
```
Expand Down

0 comments on commit 99948e0

Please sign in to comment.