Update 'app/Exceptions/Handler.php'

pull/137/head
azizi 3 years ago
parent 8213e289a7
commit aeafb60f0c

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

Loading…
Cancel
Save