1
0
Fork 0
pixelfed/app/Exceptions/Handler.php

62 lines
1.2 KiB
PHP
Raw Normal View History

2018-04-15 23:56:48 +00:00
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
2020-05-29 07:01:32 +00:00
use Throwable;
2021-05-28 05:06:47 +00:00
use League\OAuth2\Server\Exception\OAuthServerException;
use Zttp\ConnectionException;
2018-04-15 23:56:48 +00:00
class Handler extends ExceptionHandler
{
2021-05-28 05:06:47 +00:00
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
OAuthServerException::class,
ConnectionException::class
2021-05-28 05:06:47 +00:00
];
2018-04-15 23:56:48 +00:00
2021-05-28 05:06:47 +00:00
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
2018-04-15 23:56:48 +00:00
2021-05-28 05:06:47 +00:00
/**
* Report or log an exception.
*
* @param \Exception $exception
*
* @return void
*/
public function report(Throwable $exception)
{
parent::report($exception);
}
2018-04-15 23:56:48 +00:00
2021-05-28 05:06:47 +00:00
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
*
* @return \Illuminate\Http\Response
*/
public function render($request, Throwable $exception)
{
if ($request->wantsJson())
return response()->json(
['error' => $exception->getMessage()],
method_exists($exception, 'getStatusCode') ? $exception->getStatusCode() : 500
);
return parent::render($request, $exception);
}
2018-04-15 23:56:48 +00:00
}