Merge pull request 'Update 'app/Exceptions/Handler.php'' (#137) from dev into master

Reviewed-on: WillaEngine-Project/WillaEngine#137
BE.addEventListener
azizi 3 years ago
commit 326a539988

@ -2,13 +2,13 @@
namespace App\Exceptions; namespace App\Exceptions;
use Throwable;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
use WM\Core\Exceptions\HasRelationException;
use WM\Core\Exceptions\ValidationErrorException; use WM\Core\Exceptions\ValidationErrorException;
use WM\Core\Services\Responser; use WM\Core\Services\Responser;
use WM\WebBuilder\Exceptions\SiteBannedException; use WM\WebBuilder\Exceptions\SiteBannedException;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
{ {
/** /**
@ -33,7 +33,7 @@ class Handler extends ExceptionHandler
/** /**
* Report or log an exception. * Report or log an exception.
* *
* @param \Throwable $exception * @param \Throwable $exception
* @return void * @return void
*/ */
public function report(Throwable $exception) public function report(Throwable $exception)
@ -48,8 +48,8 @@ class Handler extends ExceptionHandler
/** /**
* Render an exception into an HTTP response. * Render an exception into an HTTP response.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Throwable $exception * @param \Throwable $exception
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function render($request, Throwable $exception) public function render($request, Throwable $exception)
@ -58,6 +58,8 @@ class Handler extends ExceptionHandler
return response()->json(Responser::error($exception->getMessageBody(), $exception->getMessageInfo()), 422); return response()->json(Responser::error($exception->getMessageBody(), $exception->getMessageInfo()), 422);
} elseif ($exception instanceof SiteBannedException) { } elseif ($exception instanceof SiteBannedException) {
return response()->view('webBuilder::errors.template_disabled', ['error' => 'business banned']); return response()->view('webBuilder::errors.template_disabled', ['error' => 'business banned']);
} elseif ($exception instanceof HasRelationException) {
return response()->json(Responser::error([$exception->getMessage()]), 422);
} }
return parent::render($request, $exception); return parent::render($request, $exception);

Loading…
Cancel
Save