Skip to content

Commit 00b0ce0

Browse files
Merge branch '8.x'
2 parents 1ec905f + 4080566 commit 00b0ce0

File tree

7 files changed

+80
-4
lines changed

7 files changed

+80
-4
lines changed

src/Illuminate/Foundation/Exceptions/Handler.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use Illuminate\Session\TokenMismatchException;
2222
use Illuminate\Support\Arr;
2323
use Illuminate\Support\Facades\Auth;
24-
use Illuminate\Support\Facades\View;
2524
use Illuminate\Support\Reflector;
2625
use Illuminate\Support\Traits\ReflectsClosures;
2726
use Illuminate\Support\ViewErrorBag;

src/Illuminate/Support/Testing/Fakes/BusFake.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ public function assertChained(array $expectedChain)
200200

201201
if ($command instanceof Closure) {
202202
[$command, $callback] = [$this->firstClosureParameterType($command), $command];
203+
} elseif (! is_string($command)) {
204+
$command = get_class($command);
203205
}
204206

205207
PHPUnit::assertTrue(

src/Illuminate/View/Engines/CompilerEngine.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Illuminate\View\Engines;
44

5-
use ErrorException;
65
use Illuminate\Filesystem\Filesystem;
76
use Illuminate\View\Compilers\CompilerInterface;
7+
use Illuminate\View\ViewException;
88
use Throwable;
99

1010
class CompilerEngine extends PhpEngine
@@ -76,7 +76,7 @@ public function get($path, array $data = [])
7676
*/
7777
protected function handleViewException(Throwable $e, $obLevel)
7878
{
79-
$e = new ErrorException($this->getMessage($e), 0, 1, $e->getFile(), $e->getLine(), $e);
79+
$e = new ViewException($this->getMessage($e), 0, 1, $e->getFile(), $e->getLine(), $e);
8080

8181
parent::handleViewException($e, $obLevel);
8282
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Illuminate\View;
4+
5+
use ErrorException;
6+
7+
class ViewException extends ErrorException
8+
{
9+
/**
10+
* Report the exception.
11+
*
12+
* @return void
13+
*/
14+
public function report()
15+
{
16+
$exception = $this->getPrevious();
17+
18+
if ($exception && method_exists('report', $exception)) {
19+
$exception->report();
20+
}
21+
}
22+
23+
/**
24+
* Render the exception into an HTTP response.
25+
*
26+
* @param \Illuminate\Http\Request $request
27+
* @return \Illuminate\Http\Response
28+
*/
29+
public function render($request)
30+
{
31+
$exception = $this->getPrevious();
32+
33+
if ($exception && method_exists($exception, 'render')) {
34+
return $exception->render($request);
35+
}
36+
}
37+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Illuminate\Tests\Integration\View;
4+
5+
use Exception;
6+
use Illuminate\Http\Response;
7+
use Illuminate\Support\Facades\Route;
8+
use Illuminate\Support\Facades\View;
9+
use Orchestra\Testbench\TestCase;
10+
11+
class RenderableViewExceptionTest extends TestCase
12+
{
13+
public function testRenderMethodOfExceptionThrownInViewGetsHandled()
14+
{
15+
Route::get('/', function () {
16+
return View::make('renderable-exception');
17+
});
18+
19+
$response = $this->get('/');
20+
21+
$response->assertSee('This is a renderable exception.');
22+
}
23+
24+
protected function getEnvironmentSetUp($app)
25+
{
26+
$app['config']->set('view.paths', [__DIR__.'/templates']);
27+
}
28+
}
29+
30+
class RenderableException extends Exception
31+
{
32+
public function render($request)
33+
{
34+
return new Response('This is a renderable exception.');
35+
}
36+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@php
2+
throw new Illuminate\Tests\Integration\View\RenderableException;
3+
@endphp
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
Hello World

0 commit comments

Comments
 (0)