<?php
namespace App\Exceptions;
use App\Traits\Json;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
use Json;
protected $dontReport = [
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
\Illuminate\Validation\ValidationException::class,
];
protected $dontFlash = [
'password',
'password_confirmation',
];
public function register()
{
$this->reportable(function (Throwable $e) {
});
}
public function render($request, Throwable $exception)
{
if($exception instanceof \Illuminate\Validation\ValidationException){
return $this->errorJson($exception->validator->errors()->first());
}
return parent::render($request, $exception);
}
}