Skip to content

Commit bca8d10

Browse files
author
Maxim Lanin
committed
Remove previous exception
1 parent 33c9e09 commit bca8d10

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/ApiException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Contracts\Support\Arrayable;
66
use Illuminate\Contracts\Support\Jsonable;
7+
use Lanin\Laravel\ApiExceptions\Contracts\ShowsPrevious;
78
use Lanin\Laravel\ApiExceptions\Contracts\ShowsTrace;
89
use Symfony\Component\Debug\Exception\FlattenException;
910

@@ -65,7 +66,7 @@ public function toArray()
6566
{
6667
$e = $this;
6768

68-
if (env('APP_DEBUG') && $this->getPrevious() !== null) {
69+
if (env('APP_DEBUG') && $e instanceof ShowsPrevious && $this->getPrevious() !== null) {
6970
$e = $this->getPrevious();
7071
}
7172

src/Contracts/ShowsPrevious.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Lanin\Laravel\ApiExceptions\Contracts;
4+
5+
interface ShowsPrevious
6+
{
7+
8+
}

src/InternalServerErrorApiException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
namespace Lanin\Laravel\ApiExceptions;
44

55
use Exception;
6+
use Lanin\Laravel\ApiExceptions\Contracts\ShowsPrevious;
67
use Lanin\Laravel\ApiExceptions\Contracts\ShowsTrace;
78

8-
class InternalServerErrorApiException extends ApiException implements ShowsTrace
9+
class InternalServerErrorApiException extends ApiException implements ShowsTrace, ShowsPrevious
910
{
1011
/**
1112
* @param string $message

0 commit comments

Comments
 (0)