Better aligned handler with core laravel
This commit is contained in:
parent
60030a774d
commit
382f155f76
|
@ -3,9 +3,7 @@
|
||||||
namespace BookStack\Exceptions;
|
namespace BookStack\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
|
||||||
use Illuminate\Auth\AuthenticationException;
|
use Illuminate\Auth\AuthenticationException;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|
||||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
@ -16,36 +14,42 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* A list of the exception types that should not be reported.
|
* A list of the exception types that are not reported.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $dontReport = [
|
protected $dontReport = [
|
||||||
AuthorizationException::class,
|
|
||||||
HttpException::class,
|
|
||||||
ModelNotFoundException::class,
|
|
||||||
ValidationException::class,
|
|
||||||
NotFoundException::class,
|
NotFoundException::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report or log an exception.
|
* A list of the inputs that are never flashed for validation exceptions.
|
||||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $dontFlash = [
|
||||||
|
'password',
|
||||||
|
'password_confirmation',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report or log an exception.
|
||||||
|
*
|
||||||
|
* @param Exception $exception
|
||||||
|
* @return void
|
||||||
*
|
*
|
||||||
* @param \Exception $e
|
|
||||||
* @return mixed
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function report(Exception $e)
|
public function report(Exception $exception)
|
||||||
{
|
{
|
||||||
return parent::report($e);
|
parent::report($exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 \Exception $e
|
* @param Exception $e
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function render($request, Exception $e)
|
public function render($request, Exception $e)
|
||||||
|
@ -117,11 +121,8 @@ class Handler extends ExceptionHandler
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the exception chain to compare against the original exception type.
|
* Check the exception chain to compare against the original exception type.
|
||||||
* @param Exception $e
|
|
||||||
* @param $type
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
protected function isExceptionType(Exception $e, $type)
|
protected function isExceptionType(Exception $e, string $type): bool
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
if (is_a($e, $type)) {
|
if (is_a($e, $type)) {
|
||||||
|
@ -133,10 +134,8 @@ class Handler extends ExceptionHandler
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get original exception message.
|
* Get original exception message.
|
||||||
* @param Exception $e
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
protected function getOriginalMessage(Exception $e)
|
protected function getOriginalMessage(Exception $e): string
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
$message = $e->getMessage();
|
$message = $e->getMessage();
|
||||||
|
|
|
@ -5,7 +5,6 @@ class NotFoundException extends PrettyException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NotFoundException constructor.
|
* NotFoundException constructor.
|
||||||
* @param string $message
|
|
||||||
*/
|
*/
|
||||||
public function __construct($message = 'Item not found')
|
public function __construct($message = 'Item not found')
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue