Skip to content

Commit 955e60e

Browse files
committed
fix conflicts
2 parents 0abc9f6 + a7244f4 commit 955e60e

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

src/Illuminate/View/Engines/CompilerEngine.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
namespace Illuminate\View\Engines;
44

55
use Illuminate\Filesystem\Filesystem;
6+
use Illuminate\Http\Exceptions\HttpResponseException;
67
use Illuminate\View\Compilers\CompilerInterface;
78
use Illuminate\View\ViewException;
9+
use Symfony\Component\HttpKernel\Exception\HttpException;
810
use Throwable;
911

1012
class CompilerEngine extends PhpEngine
@@ -100,6 +102,10 @@ public function get($path, array $data = [])
100102
*/
101103
protected function handleViewException(Throwable $e, $obLevel)
102104
{
105+
if ($e instanceof HttpException || $e instanceof HttpResponseException) {
106+
parent::handleViewException($e, $obLevel);
107+
}
108+
103109
$e = new ViewException($this->getMessage($e), 0, 1, $e->getFile(), $e->getLine(), $e);
104110

105111
parent::handleViewException($e, $obLevel);

tests/View/ViewCompilerEngineTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Illuminate\View\ViewException;
1212
use Mockery as m;
1313
use PHPUnit\Framework\TestCase;
14+
use Symfony\Component\HttpKernel\Exception\HttpException;
1415

1516
class ViewCompilerEngineTest extends TestCase
1617
{
@@ -43,6 +44,30 @@ public function testViewsAreNotRecompiledIfTheyAreNotExpired()
4344
', $results);
4445
}
4546

47+
public function testRegularExceptionsAreReThrownAsViewExceptions()
48+
{
49+
$engine = $this->getEngine();
50+
$engine->getCompiler()->shouldReceive('getCompiledPath')->with(__DIR__.'/fixtures/foo.php')->andReturn(__DIR__.'/fixtures/regular-exception.php');
51+
$engine->getCompiler()->shouldReceive('isExpired')->once()->andReturn(false);
52+
53+
$this->expectException(ViewException::class);
54+
$this->expectExceptionMessage('regular exception message');
55+
56+
$engine->get(__DIR__.'/fixtures/foo.php');
57+
}
58+
59+
public function testHttpExceptionsAreNotReThrownAsViewExceptions()
60+
{
61+
$engine = $this->getEngine();
62+
$engine->getCompiler()->shouldReceive('getCompiledPath')->with(__DIR__.'/fixtures/foo.php')->andReturn(__DIR__.'/fixtures/http-exception.php');
63+
$engine->getCompiler()->shouldReceive('isExpired')->once()->andReturn(false);
64+
65+
$this->expectException(HttpException::class);
66+
$this->expectExceptionMessage('http exception message');
67+
68+
$engine->get(__DIR__.'/fixtures/foo.php');
69+
}
70+
4671
public function testThatViewsAreNotAskTwiceIfTheyAreExpired()
4772
{
4873
$engine = $this->getEngine();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
use Symfony\Component\HttpKernel\Exception\HttpException;
4+
5+
throw new HttpException(403, 'http exception message');
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
throw new Exception('regular exception message');

0 commit comments

Comments
 (0)