Skip to content

Commit

Permalink
Tweak renderable exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Apr 1, 2017
1 parent 18bb4df commit c8a9413
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Illuminate/Foundation/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Exception;
use Psr\Log\LoggerInterface;
use Illuminate\Http\Response;
use Illuminate\Routing\Router;
use Illuminate\Http\RedirectResponse;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Contracts\Container\Container;
Expand Down Expand Up @@ -106,8 +107,8 @@ protected function shouldntReport(Exception $e)
*/
public function render($request, Exception $e)
{
if (method_exists($e, 'render')) {
return $e->render($request);
if (method_exists($e, 'render') && $response = $e->render($request)) {
return Router::prepareResponse($request, $response);
}

$e = $this->prepareException($e);
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ protected function sortMiddleware(Collection $middlewares)
* @param mixed $response
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*/
public function prepareResponse($request, $response)
public static function prepareResponse($request, $response)
{
if ($response instanceof PsrResponseInterface) {
$response = (new HttpFoundationFactory)->createResponse($response);
Expand Down

0 comments on commit c8a9413

Please sign in to comment.