blessing-skin-server/app/Exceptions/Handler.php

52 lines
1.8 KiB
PHP
Raw Normal View History

2016-08-28 10:05:21 +08:00
<?php
namespace App\Exceptions;
use Exception;
2019-07-08 12:01:26 +08:00
use Illuminate\Support\Arr;
2019-08-28 17:45:25 +08:00
use Illuminate\Support\Str;
2016-08-28 10:05:21 +08:00
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*/
protected $dontReport = [
2019-07-08 12:01:26 +08:00
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
\Illuminate\Validation\ValidationException::class,
PrettyPageException::class,
2016-08-28 10:05:21 +08:00
];
2019-07-08 12:01:26 +08:00
protected function convertExceptionToArray(Exception $e)
{
return [
'message' => $e->getMessage(),
'exception' => true,
'trace' => collect($e->getTrace())
->map(function ($trace) {
return Arr::only($trace, ['file', 'line']);
})
->filter(function ($trace) {
return Arr::has($trace, 'file');
})
->map(function ($trace) {
$trace['file'] = str_replace(base_path().DIRECTORY_SEPARATOR, '', $trace['file']);
2019-07-08 12:01:26 +08:00
return $trace;
})
->filter(function ($trace) {
2019-08-29 18:56:44 +08:00
// @codeCoverageIgnoreStart
$isFromPlugins = ! app()->runningUnitTests() &&
2019-08-28 17:45:25 +08:00
Str::contains($trace['file'], resolve('plugins')->getPluginsDirs()->all());
2019-08-29 18:56:44 +08:00
// @codeCoverageIgnoreEnd
return Str::startsWith($trace['file'], 'app') || $isFromPlugins;
2019-07-08 12:01:26 +08:00
})
->values(),
];
}
2016-08-28 10:05:21 +08:00
}