From a0d19241658e548e7febaa8e30e45fc1a0ed073e Mon Sep 17 00:00:00 2001 From: printempw Date: Thu, 29 Jun 2017 21:34:02 +0800 Subject: [PATCH] Return exception in plain text for xhr requests --- app/Exceptions/Handler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 8790a1ab..758296ac 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -71,7 +71,7 @@ class Handler extends ExceptionHandler return parent::render($request, $e); } else { // hide exception details if not in debug mode - if (config('app.debug')) { + if (config('app.debug') && !$request->ajax()) { return $this->renderExceptionWithWhoops($e); } else { return $this->renderExceptionInBrief($e); @@ -108,7 +108,7 @@ class Handler extends ExceptionHandler */ protected function renderExceptionInBrief(Exception $e) { - if ($_SERVER['REQUEST_METHOD'] == "GET") { + if ($_SERVER['REQUEST_METHOD'] == "GET" && !app('request')->ajax()) { return response()->view('errors.exception', ['message' => $e->getMessage()]); } else { return $e->getMessage();