Skip to content

Commit

Permalink
Merge pull request #672 from metaliciouz/patch-1
Browse files Browse the repository at this point in the history
Update error-handling.md
  • Loading branch information
l0gicgate committed Jul 23, 2023
2 parents f8168b0 + 6d32fc6 commit 694bcd2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions docs/v4/middleware/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ You can now map custom handlers for any type of Exception or Throwable.
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;
use Slim\Factory\AppFactory;
use Slim\Psr7\Response;

require __DIR__ . '/../vendor/autoload.php';

Expand All @@ -62,7 +61,9 @@ $customErrorHandler = function (
bool $logErrorDetails,
?LoggerInterface $logger = null
) use ($app) {
$logger->error($exception->getMessage());
if ($logger) {
$logger->error($exception->getMessage());
}

$payload = ['error' => $exception->getMessage()];

Expand Down Expand Up @@ -235,7 +236,7 @@ The base class `HttpSpecializedException` extends `Exception` and comes with the

You can extend the `HttpSpecializedException` class if they need any other response codes that we decide not to provide with the base repository. Example if you wanted a 504 gateway timeout exception that behaves like the native ones you would do the following:
```php
class HttpForbiddenException extends HttpSpecializedException
class HttpGatewayTimeoutException extends HttpSpecializedException
{
protected $code = 504;
protected $message = 'Gateway Timeout.';
Expand Down

0 comments on commit 694bcd2

Please sign in to comment.