mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* Update dependencies hpdocumentor/reflection-docblock (5.3.0) hpspec/prophecy (v1.15.0) ymfony/debug (v4.4.41) barryvdh/laravel-debugbar (v3.6.7 => v3.7.0) composer/ca-bundle (1.3.2 => 1.3.3) composer/class-map-generator (1.0.0) composer/composer (2.3.7 => 2.4.1) doctrine/annotations (1.13.2 => 1.13.3) doctrine/event-manager (1.1.1 => 1.1.2) doctrine/inflector (2.0.4 => 2.0.5) fakerphp/faker (v1.19.0 => v1.20.0) graham-campbell/result-type (v1.0.4 => v1.1.0) guzzlehttp/guzzle (7.4.5 => 7.5.0) guzzlehttp/promises (1.5.1 => 1.5.2) guzzlehttp/psr7 (2.4.0 => 2.4.1) laravel/dusk (v6.24.0 => v6.25.1) laravel/framework (v8.83.16 => v8.83.23) laravel/serializable-closure (v1.2.0 => v1.2.1) laravel/socialite (v5.5.2 => v5.5.5) maximebf/debugbar (v1.18.0 => v1.18.1) mews/purifier (3.3.7 => 3.3.8) mockery/mockery (1.5.0 => 1.5.1) monolog/monolog (2.7.0 => 2.8.0) nesbot/carbon (2.58.0 => 2.62.1) nikic/php-parser (v4.14.0 => v4.15.1) paragonie/constant_time_encoding (v2.6.1 => v2.6.3) phpmailer/phpmailer (v6.6.0 => v6.6.4) phpoption/phpoption (1.8.1 => 1.9.0) phpseclib/phpseclib (3.0.14 => 3.0.16) phpstan/phpstan (1.7.12 => 1.8.5) phpunit/php-code-coverage (9.2.15 => 9.2.17) phpunit/phpunit (9.5.20 => 9.5.24) psy/psysh (v0.11.5 => v0.11.8) sebastian/type (3.0.0 => 3.1.0) seld/phar-utils (1.2.0 => 1.2.1) seld/signal-handler (2.0.1) symfony/console (v5.4.9 => v5.4.12) symfony/css-selector (v5.4.3 => v5.4.11) symfony/deprecation-contracts (v2.5.1 => v2.5.2) symfony/error-handler (v5.4.9 => v5.4.11) symfony/event-dispatcher-contracts (v2.5.1 => v2.5.2) symfony/filesystem (v5.4.9 => v5.4.12) symfony/finder (v5.4.8 => v5.4.11) symfony/http-foundation (v5.4.9 => v5.4.12) symfony/http-kernel (v5.4.9 => v5.4.12) symfony/mime (v5.4.9 => v5.4.12) symfony/options-resolver (v5.4.3 => v5.4.11) symfony/process (v5.4.8 => v5.4.11) symfony/routing (v5.4.8 => v5.4.11) symfony/service-contracts (v2.5.1 => v2.5.2) symfony/string (v5.4.9 => v5.4.12) symfony/translation (v5.4.9 => v5.4.12) symfony/translation-contracts (v2.5.1 => v2.5.2) symfony/var-dumper (v5.4.9 => v5.4.11) symfony/yaml (v4.4.37 => v4.4.45) tecnickcom/tcpdf (6.4.4 => 6.5.0) * changes * try again * Fix some issues because the message is changing between versions, just avoids it.
73 lines
2.4 KiB
PHP
73 lines
2.4 KiB
PHP
<?php
|
|
/**
|
|
* MaximumExecutionTimeExceeded.php
|
|
*
|
|
* Show nice explanation if the user hits their configured PHP max_execution_time
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*
|
|
* @link https://www.librenms.org
|
|
*
|
|
* @copyright 2020 Tony Murray
|
|
* @author Tony Murray <murraytony@gmail.com>
|
|
*/
|
|
|
|
namespace LibreNMS\Exceptions;
|
|
|
|
use Illuminate\Support\Str;
|
|
use LibreNMS\Interfaces\Exceptions\UpgradeableException;
|
|
use Symfony\Component\ErrorHandler\Error\FatalError;
|
|
|
|
class MaximumExecutionTimeExceeded extends \Exception implements UpgradeableException
|
|
{
|
|
/**
|
|
* Try to convert the given Exception to a FilePermissionsException
|
|
*
|
|
* @param \Exception $exception
|
|
* @return static|null
|
|
*/
|
|
public static function upgrade($exception)
|
|
{
|
|
// cannot write to storage directory
|
|
if ($exception instanceof FatalError &&
|
|
Str::startsWith($exception->getMessage(), 'Maximum execution time of')) {
|
|
return new static($exception->getMessage(), $exception->getCode(), $exception);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Render the exception into an HTTP or JSON response.
|
|
*
|
|
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
|
|
*/
|
|
public function render(\Illuminate\Http\Request $request)
|
|
{
|
|
$title = preg_match('/ (\d+) /', $this->message, $matches)
|
|
? trans_choice('exceptions.maximum_execution_time_exceeded.title', $matches[1], ['seconds' => $matches[1]])
|
|
: $this->getMessage();
|
|
|
|
$message = trans('exceptions.maximum_execution_time_exceeded.message');
|
|
|
|
return $request->wantsJson() ? response()->json([
|
|
'status' => 'error',
|
|
'message' => "$title: $message",
|
|
]) : response()->view('errors.generic', [
|
|
'title' => $title,
|
|
'content' => $message,
|
|
]);
|
|
}
|
|
}
|