Updated exceptions package
This commit is contained in:
@@ -39,12 +39,13 @@ class RedirectDisplayer implements DisplayerInterface
|
|||||||
* Get the error response associated with the given exception.
|
* Get the error response associated with the given exception.
|
||||||
*
|
*
|
||||||
* @param \Exception $exception
|
* @param \Exception $exception
|
||||||
|
* @param string $id
|
||||||
* @param int $code
|
* @param int $code
|
||||||
* @param string[] $headers
|
* @param string[] $headers
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function display(Exception $exception, $code, array $headers)
|
public function display(Exception $exception, $id, $code, array $headers)
|
||||||
{
|
{
|
||||||
return redirect()->guest('auth/login');
|
return redirect()->guest('auth/login');
|
||||||
}
|
}
|
||||||
@@ -62,13 +63,14 @@ class RedirectDisplayer implements DisplayerInterface
|
|||||||
/**
|
/**
|
||||||
* Can we display the exception?
|
* Can we display the exception?
|
||||||
*
|
*
|
||||||
* @param \Exception $exception
|
* @param \Exception $original
|
||||||
|
* @param \Exception $transformed
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function canDisplay(Exception $exception)
|
public function canDisplay(Exception $original, Exception $transformed)
|
||||||
{
|
{
|
||||||
$redirect = $exception instanceof HttpExceptionInterface && $exception->getStatusCode() === 401;
|
$redirect = $transformed instanceof HttpExceptionInterface && $transformed->getStatusCode() === 401;
|
||||||
|
|
||||||
return $redirect && !$this->request->is('api*');
|
return $redirect && !$this->request->is('api*');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,11 +37,12 @@ class ApiFilter
|
|||||||
* Filter and return the displayers.
|
* Filter and return the displayers.
|
||||||
*
|
*
|
||||||
* @param \GrahamCampbell\Exceptions\Displayers\DisplayerInterface[] $displayers
|
* @param \GrahamCampbell\Exceptions\Displayers\DisplayerInterface[] $displayers
|
||||||
* @param \Exception $exception
|
* @param \Exception $original
|
||||||
|
* @param \Exception $transformed
|
||||||
*
|
*
|
||||||
* @return \GrahamCampbell\Exceptions\Displayers\DisplayerInterface[]
|
* @return \GrahamCampbell\Exceptions\Displayers\DisplayerInterface[]
|
||||||
*/
|
*/
|
||||||
public function filter(array $displayers, Exception $exception)
|
public function filter(array $displayers, Exception $original, Exception $transformed)
|
||||||
{
|
{
|
||||||
if ($this->request->is('api*')) {
|
if ($this->request->is('api*')) {
|
||||||
foreach ($displayers as $index => $displayer) {
|
foreach ($displayers as $index => $displayer) {
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@
|
|||||||
"graham-campbell/binput": "^3.2",
|
"graham-campbell/binput": "^3.2",
|
||||||
"graham-campbell/markdown": "^3.2",
|
"graham-campbell/markdown": "^3.2",
|
||||||
"graham-campbell/throttle": "^4.1",
|
"graham-campbell/throttle": "^4.1",
|
||||||
"graham-campbell/exceptions": "^3.1",
|
"graham-campbell/exceptions": "^4.0",
|
||||||
"guzzlehttp/guzzle": "^6.0.2",
|
"guzzlehttp/guzzle": "^6.0.2",
|
||||||
"jenssegers/date": "^3.0",
|
"jenssegers/date": "^3.0",
|
||||||
"mccool/laravel-auto-presenter": "^3.1",
|
"mccool/laravel-auto-presenter": "^3.1",
|
||||||
|
|||||||
@@ -72,4 +72,38 @@ return [
|
|||||||
'CachetHQ\Cachet\Exceptions\Filters\ApiFilter',
|
'CachetHQ\Cachet\Exceptions\Filters\ApiFilter',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Displayer
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may define the default displayer for your application.
|
||||||
|
|
|
||||||
|
| This displayer will be used if your filters have filtered out all the
|
||||||
|
| displayers, otherwise leaving us unable to displayer the exception.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => 'GrahamCampbell\Exceptions\Displayers\HtmlDisplayer',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Exception Levels
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here are each of the log levels for the each exception.
|
||||||
|
|
|
||||||
|
| If an exception passes an instance of test for each key, then the log
|
||||||
|
| level used is the value associated with each key.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'levels' => [
|
||||||
|
'Illuminate\Session\TokenMismatchException' => 'notice',
|
||||||
|
'Illuminate\Database\Eloquent\ModelNotFoundException' => 'warning',
|
||||||
|
'Symfony\Component\HttpKernel\Exception\HttpExceptionInterface' => 'warning',
|
||||||
|
'Symfony\Component\Debug\Exception\FatalErrorException' => 'critical',
|
||||||
|
'Exception' => 'error',
|
||||||
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user