Jellyfrog f526ba326b Laravel 7.x Shift (#11676)
* Shift bindings

PHP 5.5.9+ adds the new static `class` property which provides the fully qualified class name. This is preferred over using class name strings as these references are checked by the parser.

* Shift core files

* Shift to Throwable

* Shift Laravel dependencies
Add laravel/ui dependency
Use our fork of string-blade-compiler

* Shift config files

Default config files

In an effort to make upgrading the constantly changing config files
easier, Shift defaulted them so you can review the commit diff for
changes. Moving forward, you should use ENV variables or create a
separate config file to allow the core config files to remain
automatically upgradeable.

Restore config header comment

* Remove duplicate named routes

* add basic trust host middleware

* Trusted proxies should be default null

* Fix missed rename

* wip

* Rename routes

* Update trustedproxy.php

* Update Kernel.php

* revert trustedproxy.php

It only accepted '*' and not ['*']

* Fix tests

fake request was causing the error

Co-authored-by: Laravel Shift <shift@laravelshift.com>
Co-authored-by: Tony Murray <murraytony@gmail.com>
2020-07-09 08:22:50 -05:00

73 lines
2.3 KiB
PHP

<?php
namespace App\Exceptions;
use Throwable;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
\Illuminate\Session\TokenMismatchException::class,
\Illuminate\Validation\ValidationException::class,
];
/**
* A list of the exceptions that can be upgraded. Checked in order.
*
* @var array
*/
protected $upgradable = [
\LibreNMS\Exceptions\FilePermissionsException::class,
\LibreNMS\Exceptions\DatabaseConnectException::class,
\LibreNMS\Exceptions\DuskUnsafeException::class,
\LibreNMS\Exceptions\UnserializableRouteCache::class,
\LibreNMS\Exceptions\MaximumExecutionTimeExceeded::class,
];
public function render($request, Throwable $exception)
{
// If for some reason Blade hasn't been registered, try it now
try {
if (!app()->bound('view')) {
app()->register(\Illuminate\View\ViewServiceProvider::class);
app()->register(\Illuminate\Translation\TranslationServiceProvider::class);
}
} catch (\Exception $e) {
// continue without view
}
// try to upgrade generic exceptions to more specific ones
if (!config('app.debug')) {
foreach ($this->upgradable as $class) {
if ($new = $class::upgrade($exception)) {
return parent::render($request, $new);
}
}
}
return parent::render($request, $exception);
}
protected function convertExceptionToArray(Throwable $e)
{
// override the non-debug error output to clue in user on how to debug
if (!config('app.debug') && !$this->isHttpException($e)) {
return ['message' => 'Server Error: Set APP_DEBUG=true to see details.'];
}
return parent::convertExceptionToArray($e);
}
}