Skip to content

Commit aa9c37b

Browse files
committed
Updates
1 parent 18bbfc1 commit aa9c37b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/Exception/Protocol/ProtocolException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,9 @@ public function toResponse($request = null): Response
192192

193193
return $response;
194194
}
195+
196+
public function getInnerException(): ?Throwable
197+
{
198+
return $this->originalException;
199+
}
195200
}

tests/Protocol/ErrorReportingTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
use Flat3\Lodata\Tests\TestCase;
1919
use Flat3\Lodata\Type;
2020
use Generator;
21+
use Illuminate\Foundation\Exceptions\Handler;
22+
use Illuminate\Support\Facades\Log;
2123
use Illuminate\Testing\TestResponse;
2224

2325
class ErrorReportingTest extends TestCase
@@ -90,11 +92,20 @@ public function test_get_original_exception()
9092
->path('/divzero()')
9193
);
9294

95+
$innerException = $testResponse->exception->getOriginalException();
96+
9397
if (PHP_VERSION_ID > 80000) {
94-
$this->assertInstanceOf(DivisionByZeroError::class, $testResponse->exception->getOriginalException());
98+
$this->assertInstanceOf(DivisionByZeroError::class, $innerException);
9599
} else {
96-
$this->assertInstanceOf(ErrorException::class, $testResponse->exception->getOriginalException());
100+
$this->assertInstanceOf(ErrorException::class, $innerException);
97101
}
102+
103+
$spy = Log::spy();
104+
$handler = app(Handler::class);
105+
$handler->report($testResponse->exception);
106+
$spy->shouldHaveReceived('error', function ($message, $context) use ($innerException) {
107+
return $message === $innerException->getMessage() && $context['exception'] instanceof DivisionByZeroError;
108+
});
98109
}
99110

100111
public function test_stream_error()

0 commit comments

Comments
 (0)