namespace BookStack\Exceptions;
use Exception;
-use Illuminate\Contracts\Validation\ValidationException;
+use Illuminate\Auth\AuthenticationException;
+use Illuminate\Validation\ValidationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
-use PhpSpec\Exception\Example\ErrorException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Auth\Access\AuthorizationException;
/**
* Report or log an exception.
- *
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
+ * @return mixed
*/
public function report(Exception $e)
{
return redirect()->guest('login');
}
+
+ /**
+ * Convert a validation exception into a JSON response.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Validation\ValidationException $exception
+ * @return \Illuminate\Http\JsonResponse
+ */
+ protected function invalidJson($request, ValidationException $exception)
+ {
+ return response()->json($exception->errors(), $exception->status);
+ }
}