/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { if ($this->isHttpException($e)) { return $this->renderHttpException($e); } elseif ($e instanceof OAuthException) { return Response::json(['error' => $e->errorType, 'message' => $e->getMessage()], $e->httpStatusCode); } if (config('app.debug')) { $handler = new \Whoops\Handler\PrettyPageHandler(); $handler->setEditor('sublime'); $whoops = new \Whoops\Run(); $whoops->pushHandler($handler); return response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); } return parent::render($request, $e); }
public static function enableDebug() { // 设置 PHP 调试环境 ini_set('display_errors', 1); error_reporting(E_ALL | E_STRICT); // 开启 debug log BzfDebug::startDebugLogCollector(); // 当前目录 autoload \Core\Plugin\SystemHelper::addAutoloadPath(realpath(dirname(__FILE__))); $handler = new \Whoops\Handler\PrettyPageHandler(); // 增加额外的日志输出 $handler->addDataTableCallback('LOGS', function () { // 取得 logCollector $logCollector = BzfDebug::startDebugLogCollector(); $logArray = $logCollector->getLogArray(); // 由于 debug 只支持 key-->value 显示,我们只能简单一点了 $displayArray = array(); $index = 0; foreach ($logArray as $logItem) { $displayArray['' . sprintf('%02d', $index) . '|' . str_pad($logItem['level'], 10, ' ', STR_PAD_LEFT) . '|' . $logItem['source']] = $logItem['msg']; $index++; } return $displayArray; }); $run = new \Whoops\Run(); $run->pushHandler($handler); $run->register(); }
/** * Render an exception into an HTTP response using Whoops. * * @return \Illuminate\Http\Response */ protected function whoops(Exception $e) { $whoops = new \Whoops\Run(); $handler = new \Whoops\Handler\PrettyPageHandler(); $handler->setEditor('sublime'); $whoops->pushHandler($handler); return response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); }
/** * Render an exception using Whoops. * * @param \Exception $e * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops(Exception $e) { $whoops = new \Whoops\Run(); $handler = new \Whoops\Handler\PrettyPageHandler(); $handler->addResourcePath(public_path()); $handler->addCustomCss('css/whoops.min.css'); $whoops->pushHandler($handler); return new \Illuminate\Http\Response($whoops->handleException($e)); }
/** * Render an exception using Whoops. * * @param \Exception $e * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops(Exception $e) { $whoops = new \Whoops\Run(); $handler = new \Whoops\Handler\PrettyPageHandler(); if ($e instanceof ValidationException) { $handler->addDataTable('Validation Errors', $e->validator->errors()->all()); } $whoops->pushHandler($handler); return new \Illuminate\Http\Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); }
public static function stop($name = "User Debug", $array_vars = array()) { if (is_array($name)) { $array_vars = $name; $name = "User Debug"; } // $Handler = new Whoops\Handler\PrettyPageHandler(); $Handler->handleUserDebug($name, $array_vars); }
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { if (config('app.debug')) { $whoopsHandler = new \Whoops\Handler\PrettyPageHandler(); $whoopsHandler->setEditor('sublime'); $whoops = new \Whoops\Run(); $whoops->pushHandler($whoopsHandler); return $whoops->handleException($e); } else { return parent::render($request, $e); } }
public static function registerErrorHandler() { // only show errors in dev environment if (static::$Config['environment'] == 'dev') { static::$whoops = new \Whoops\Run(); $Handler = new \Whoops\Handler\PrettyPageHandler(); $Handler->setPageTitle("Divergence Error"); static::$whoops->pushHandler($Handler); static::$whoops->register(); } else { error_reporting(0); } }
/** * @param BaseApp $app */ public function register(BaseApp $app) { $app->set('errorLogger', function (BaseApp $app) { $logger = new \Monolog\Logger('errorLogger'); $handler = new \Monolog\Handler\ErrorLogHandler(); if (!$app->isCli()) { $handler->pushProcessor(new \Monolog\Processor\WebProcessor()); $format = '%level_name%: %message% %extra.server%%extra.url%'; } else { $format = '%level_name%: %message%'; } $handler->setFormatter(new \Monolog\Formatter\LineFormatter($format, null, true)); $logger->pushHandler($handler); return $logger; }); $app->set('whoopsDebugErrorPageHandler', function (BaseApp $app) { $prettyPageHandler = new \Whoops\Handler\PrettyPageHandler(); if ($app->getConfig()->has('editor')) { $prettyPageHandler->setEditor($app->getConfig()->get('editor')); } return $prettyPageHandler; }); $app->set('whoopsErrorHandler', function (BaseApp $app) { $plainTextHandler = new \Whoops\Handler\PlainTextHandler(); $plainTextHandler->setLogger($app->get('errorLogger')); if (!$app->isCli()) { $plainTextHandler->loggerOnly(true); } return $plainTextHandler; }); $app->set('whoops', function (BaseApp $app) { $whoops = new \Whoops\Run(); if (ini_get('display_errors')) { $whoops->pushHandler($app->get('whoopsDebugErrorPageHandler')); } // Handles cli output and logging $whoops->pushHandler($app->get('whoopsErrorHandler')); return $whoops; }); $app->get('whoops')->register(); }
public function __construct() { $CI =& get_instance(); $_env = ENVIRONMENT; require_once __DIR__ . '/../../vendor/autoload.php'; $whoops = new Whoops\Run(); // Configure the PrettyPageHandler: $errorPage = new Whoops\Handler\PrettyPageHandler(); $errorPage->setPageTitle("Oh No, It's broken!"); // Set the page's title $errorPage->setEditor("sublime"); // Set the editor used for the "Open" link $errorPage->addDataTable("Extra Info", array("route" => $CI->uri->uri_string())); $whoops->pushHandler($errorPage); if ($CI->input->is_ajax_request() == true) { $whoops->pushHandler(new Whoops\Handler\JsonResponseHandler()); } // Debug true in env development if ($_env == 'development') { $whoops->register(); $this->whoops = $whoops; } }
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { $debug = config("app.debug"); $debugbar = $debug && config("debugbar.enabled") !== false && !$request->ajax(); if (app()->environment('local')) { if ($request->ajax()) { $handler = new \Whoops\Handler\JsonResponseHandler(); } else { $handler = new \Whoops\Handler\PrettyPageHandler(); $handler->setEditor('sublime'); } $whoops = new \Whoops\Run(); $whoops->pushHandler($handler); $whoops->allowQuit(false); $whoops->writeToOutput(true); $status = 500; $headers = []; if ($e instanceof HttpExceptionInterface) { $status = $e->getStatusCode(); $headers = $e->getHeaders(); } $response = response($whoops->handleException($e), $status, $headers); } else { $response = parent::render($request, $e); } if ($debugbar) { $debugbar = app()->make('debugbar'); $debugbar->boot(); $debugbar->addException($e); $response = $debugbar->modifyResponse($request, $response); } if (Subdomens::is('api')) { $response = Api::addCORSHeaders($response); } return $response; }
public static function ini($root = "") { require $root . "../core/Associates/Whoops/vendor/autoload.php"; // if (Config::get('loggin.debug')) { $whoops = new \Whoops\Run(); $errorPage = new \Whoops\Handler\PrettyPageHandler(); // $errorPage->setPageTitle(Config::get('loggin.msg')); // Set the page's title $errorPage->setEditor("sublime"); // $whoops->pushHandler($errorPage); $whoops->register(); } else { $whoops = new \Whoops\Run(); $errorPage = new \Whoops\Handler\PlainTextHandler(); $errorPage->msg = Config::get('loggin.msg'); $errorPage->bg_color = Config::get('loggin.bg'); $errorPage->handle(); $whoops->pushHandler($errorPage); $whoops->register(); } }
public function onError(ErrorEvent $event) { if (php_sapi_name() == "cli") { return; } header('X-Error-Message: ' . $event->getException()->getMessage(), true, 500); $whoops = new \Whoops\Run(); $request = $event->getContext()->getRequest(); $handler = new \Whoops\Handler\PrettyPageHandler(); $event->getContext()->getActionName(); $prev = $event->getException()->getPrevious(); $fwkTable = array('Application name' => $event->getApplication()->getName(), 'Action name' => $event->getContext()->getActionName(), 'Context state' => $event->getContext()->getState(), 'Context error' => $event->getContext()->getError()); $parents = $this->getParentExceptionsMessage($event->getException()); if (!is_array($parents)) { $parents = array(); } foreach ($parents as $idx => $exp) { $fwkTable['Parent Exception #' . $idx] = $exp; } $handler->addDataTable('Fwk\\Core Informations', $fwkTable); $handler->addDataTable('Request Informations', array('URI' => $request->getUri(), 'Request URI' => $request->getRequestUri(), 'Path Info' => $request->getPathInfo(), 'Query String' => $request->getQueryString() ?: '<none>', 'HTTP Method' => $request->getMethod(), 'Script Name' => $request->getScriptName(), 'Base Path' => $request->getBasePath(), 'Base URL' => $request->getBaseUrl(), 'Scheme' => $request->getScheme(), 'Port' => $request->getPort(), 'Host' => $request->getHost())); $whoops->pushHandler($handler); $whoops->register(); }
/** * Render an exception using Whoops. * * @param \Exception $e * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops(Exception $e) { $whoops = new \Whoops\Run(); $ppHandler = new \Whoops\Handler\PrettyPageHandler(); $ppHandler->setPageTitle('Crap!'); $ppHandler->setResourcesPath(public_path()); $ppHandler->addCustomCss('/css/whoops.css'); // $ppHandler->addDataTable('Dashboard Details', [ // 'User ID' => Auth::user()->id // ]); $ppHandler->setEditor('sublime'); $whoops->pushHandler($ppHandler); return new \Illuminate\Http\Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); }
// Load Whoops /*-----------------------------------------------------*/ use Composer\Autoload\ClassLoader; use Illuminate\Cache\CacheManager; use Illuminate\Cache\MemcachedConnector; use Themosis\Configuration\Constant; use Themosis\Configuration\Images; use Themosis\Configuration\Menu; use Themosis\Configuration\Sidebar; use Themosis\Configuration\Support; use Themosis\Configuration\Template; use Themosis\Core\AdminLoader; use Themosis\Core\WidgetLoader; use Themosis\Facades\Config; $run = new \Whoops\Run(); $handler = new \Whoops\Handler\PrettyPageHandler(); // Set the title of the error page: $handler->setPageTitle("Whoops! There was a problem."); $run->pushHandler($handler); // Add a special handler to deal with AJAX requests with an // equally-informative JSON response. Since this handler is // first in the stack, it will be executed before the error // page handler, and will have a chance to decide if anything // needs to be done. if (\Whoops\Util\Misc::isAjaxRequest()) { $run->pushHandler(new \Whoops\Handler\JsonResponseHandler()); } // Register the handler with PHP, and you're set! $run->register(); /*----------------------------------------------------*/ // Set theme's configurations.
<?php /** * DEVELOPMENT MODE */ /** * Debug stacktrace using WHOOPS */ $app->config->catch = false; $handler = new Whoops\Handler\PrettyPageHandler(); $handler->addDataTableCallback('App Uri', function () use($app) { return (array) $app->context->request->uri; }); $handler->addDataTableCallback('App Route', function () use($app) { return (array) $app->context->route; }); $handler->addDataTableCallback('App Invokable', function () use($app) { $invokable = $app->context->invokable; array_shift($invokable->params); return (array) $invokable; }); $handler->addDataTableCallback('App Access', function () use($app) { return (array) $app->context->access; }); $handler->addDataTableCallback('App Response', function () use($app) { return (array) $app->context->response; }); $whoops = new Whoops\Run(); $whoops->pushHandler($handler)->register(); /** * Vardump
$includeFiles = (require DOCUMENT_ROOT . '/vendor/composer' . '/autoload_files.php'); foreach ($includeFiles as $file) { Composer\Autoload\includeFile($file); } $loader->register(true); /** * Error handler */ error_reporting(E_ALL); ini_set('display_errors', 'On'); ini_set('log_errors', 'On'); ini_set('error_log', sprintf(DOCUMENT_ROOT . '/data/logs/php_errors-%s.txt', date('Y-m-d'))); if (php_sapi_name() !== 'cli') { if (IS_DEV) { $whoops = new \Whoops\Run(); $handler = new \Whoops\Handler\PrettyPageHandler(); $handler->setEditor('sublime'); $whoops->pushHandler($handler); $whoops->register(); } else { set_error_handler(function ($errno, $errstr, $errfile, $errline) { if (error_reporting() & $errno) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } }); set_exception_handler(function ($e) { error_log($e); abort(500); }); register_shutdown_function(function () { $e = error_get_last();
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL & ~E_NOTICE); require 'instance.php'; /** * Authentication setup */ use Colorium\Stateful\Auth; use Pictobox\Model\User; Auth::factory(function ($id) { return User::one(['id' => $id]); }); /** * Debug mode */ use Colorium\Http; $request = Http\Request::globals(); $request->local[] = '10.0.2.2'; if ($request->local()) { $app->catch = false; $handler = new Whoops\Handler\PrettyPageHandler(); $handler->addDataTableCallback('App Request', function () use($request) { return (array) $request; }); $whoops = new Whoops\Run(); $whoops->pushHandler($handler)->register(); } /** * Execute default context */ $app->run()->end();
$app['errorHandler'] = function (Container $c) { if (version_compare(phpversion(), '7.0.0', '<') && class_exists('League\\BooBoo\\Runner')) { $runner = new League\BooBoo\Runner(); $accept = $c['router']->getContainer()['request']->getHeader('Accept'); $accept = join(' ', $accept); // If we accept html, show html, else show json if (strpos($accept, 'html') !== false) { $runner->pushFormatter(new League\BooBoo\Formatter\HtmlTableFormatter()); } else { $runner->pushFormatter(new League\BooBoo\Formatter\JsonFormatter()); } $runner->register(); } else { if (class_exists('Whoops\\Run')) { $run = new Whoops\Run(); $handler = new Whoops\Handler\PrettyPageHandler(); $handler->setPageTitle('Parvula Error'); $handler->addDataTable('Parvula', ['Version' => _VERSION_]); $run->pushHandler($handler); if (Whoops\Util\Misc::isAjaxRequest()) { $run->pushHandler(new Whoops\Handler\JsonResponseHandler()); } $run->register(); if (class_exists('Monolog\\Logger')) { // Be sure that Monolog is still register Monolog\ErrorHandler::register($c['loggerHandler']); } return $run; } } };
<?php echo $tpl->escapeButPreserveUris($comment); ?> </div> <?php } ?> </div> </div> <?php } ?> <div class="help"> <div class="label">Help : <a href="<?php echo Whoops\Handler\PrettyPageHandler::searchGoogle($message); ?> " target="_blank" title="Search for this error in Google"> <div class="help_icon help_google"></div> </a> <a href="<?php echo Whoops\Handler\PrettyPageHandler::searchStackoverflow($message); ?> " target="_blank" title="Search for this error in Stackoverflow"> <div class="help_icon help_so"></div> </a> </div> </div> </div>
<?php @ob_start(); set_error_handler(function () { }); error_reporting(E_ALL); $autoload = __DIR__ . '/../vendor/autoload.php'; if (!file_exists($autoload)) { exit('Missing /vendor/'); } require $autoload; $handler = new \Whoops\Handler\PrettyPageHandler(); $handler->setEditor('phpstorm'); $whoops = new \Whoops\Run(); $whoops->pushHandler($handler); require __DIR__ . '/helpers/functions.php'; spl_autoload_register(function ($class) { if (substr($class, 0, 6) != 'Unity\\') { return; } $name = str_replace('\\', '/', $class); $name = str_replace('Unity/', '', $name); $file = $name; $path = __DIR__ . '/lib/' . $name . '/' . $file . '.php'; if (!file_exists($path)) { $path = __DIR__ . '/lib/' . $file . '.php'; } require $path; }); $site = start(function () { config()->storage(__DIR__ . '/_storage/');
public static function renderPretty(\Exception $e, \Phalcon\DIInterface $di) { $response = $di->get('response'); $response->setStatusCode(500, "Internal Server Error"); // Register error-handler. $run = new \Whoops\Run(); $handler = new \Whoops\Handler\PrettyPageHandler(); $handler->setPageTitle('An error occurred!'); $run->pushHandler($handler); $run->handleException($e); $response->send(); return; }
}); // a. // load generic config // detect environment // load environment-specific config // // or // // b. // detect environment // try to load pre-cached config // if fail load generic config and environment-specific, then write down compiled one if (Config::get('debug', false)) { // register whoops handler // do other job to prepare for debug } $run = new \Whoops\Run(); $handler = new \Whoops\Handler\PrettyPageHandler(); $handler->setEditor(function ($file, $line) { $translate = Config::get('path.translate', array()); foreach ($translate as $from => $to) { $file = preg_replace('#' . $from . '#', $to, $file, 1); } return "pstorm://{$file}:{$line}"; }); $JsonHandler = new \Whoops\Handler\JsonResponseHandler(); $run->pushHandler($JsonHandler); $run->pushHandler($handler); $run->register(); error_reporting(E_ALL); $app->setDeferredServices(array('validator' => '\\Ape\\Validation\\ValidationServiceProvider'));
$translator->addResource('yaml', __DIR__ . '/locales/fr.yml', 'fr'); $translator->addResource('yaml', __DIR__ . '/locales/en.yml', 'en'); return $translator; })); $app->register(new MonologServiceProvider(), array('monolog.logfile' => __DIR__ . '/log/' . $app['ENVIRONMENT'] . 'app.log', 'monolog.name' => 'app', 'monolog.level' => 300)); $app->register(new TwigServiceProvider(), array('twig.options' => array('cache' => isset($app['twig.options.cache']) ? $app['twig.options.cache'] : false, 'strict_variables' => true), 'twig.form.templates' => array('form_div_layout.html.twig', 'common/form_div_layout.html.twig'), 'twig.path' => array(__DIR__ . '/../src/Views'))); if ($app['debug']) { $app->register(new Whoops\Provider\Silex\WhoopsServiceProvider()); } if ($app['debug'] && isset($app['cache.path'])) { $app->register(new ServiceControllerServiceProvider()); $app->register(new WebProfilerServiceProvider(), array('profiler.cache_dir' => $app['cache.path'] . '/profiler')); } if ($app['debug'] && $app['whoops']) { $app->register(new Whoops\Provider\Silex\WhoopsServiceProvider()); $handler = new Whoops\Handler\PrettyPageHandler(); $handler->setEditor('sublime'); } if (isset($app['assetic.enabled']) && $app['assetic.enabled']) { $app->register(new AsseticServiceProvider(), array('assetic.options' => array('debug' => $app['debug'], 'auto_dump_assets' => $app['debug']))); $app['assetic.filter_manager'] = $app->share($app->extend('assetic.filter_manager', function ($fm, $app) { $fm->set('lessphp', new Assetic\Filter\LessphpFilter()); return $fm; })); $app['assetic.asset_manager'] = $app->share($app->extend('assetic.asset_manager', function ($am, $app) { $am->set('styles', new Assetic\Asset\AssetCache(new Assetic\Asset\GlobAsset($app['assetic.input.path_to_css'], array($app['assetic.filter_manager']->get('lessphp'))), new Assetic\Cache\FilesystemCache($app['assetic.path_to_cache']))); $am->get('styles')->setTargetPath($app['assetic.output.path_to_css']); $am->set('scripts', new Assetic\Asset\AssetCache(new Assetic\Asset\GlobAsset($app['assetic.input.path_to_js']), new Assetic\Cache\FilesystemCache($app['assetic.path_to_cache']))); $am->get('scripts')->setTargetPath($app['assetic.output.path_to_js']); return $am; }));
<?php /** * Configura a exibição de erros no Slim Framework */ if (DEBUG) { $errorPage = new Whoops\Handler\PrettyPageHandler(); $errorPage->setPageTitle("WebDevBr Erro!"); $errorPage->setEditor("sublime"); $errorPage->addDataTable("Documentação", array("Url" => "http://docs.slimframework.com/")); $whoops = new Whoops\Run(); $whoops->pushHandler($errorPage); $whoops->register(); } else { echo '{message: error}'; }
Phpfox::getService($className); } else { if (substr($name, 0, 7) == 'phpfox_') { $class = str_replace('_', '.', $class); Phpfox::getLibClass($class); } } }); require PHPFOX_DIR_LIB_CORE . 'phpfox' . PHPFOX_DS . 'phpfox.class.php'; require PHPFOX_DIR_LIB_CORE . 'error' . PHPFOX_DS . 'error.class.php'; require PHPFOX_DIR_LIB_CORE . 'module' . PHPFOX_DS . 'service.class.php'; require PHPFOX_DIR_LIB_CORE . 'module' . PHPFOX_DS . 'component.class.php'; // No need to load the debug class if the debug is disabled if (PHPFOX_DEBUG) { require_once PHPFOX_DIR_LIB_CORE . 'debug' . PHPFOX_DS . 'debug.class.php'; $handler = new Whoops\Handler\PrettyPageHandler(); $handler->setEditor('textmate'); $whoops = new Whoops\Run(); $whoops->pushHandler($handler); $whoops->register(); } PHPFOX_DEBUG ? Phpfox_Debug::start('init') : false; date_default_timezone_set('GMT'); define('PHPFOX_TIME', time()); Phpfox::getLib('setting')->set(); if (!defined('PHPFOX_NO_PLUGINS')) { Phpfox_Plugin::set(); } if (Phpfox_Request::instance()->get('ping-no-session')) { define('PHPFOX_NO_SESSION', true); define('PHPFOX_NO_APPS', true);
<?php require_once MAGENTO_ROOT . '/lib/Whoops/Run.php'; require_once MAGENTO_ROOT . '/lib/Whoops/Exception/ErrorException.php'; require_once MAGENTO_ROOT . '/lib/Whoops/Exception/Inspector.php'; require_once MAGENTO_ROOT . '/lib/Whoops/Exception/FrameIterator.php'; require_once MAGENTO_ROOT . '/lib/Whoops/Exception/Frame.php'; require_once MAGENTO_ROOT . '/lib/Whoops/Handler/HandlerInterface.php'; require_once MAGENTO_ROOT . '/lib/Whoops/Handler/Handler.php'; require_once MAGENTO_ROOT . '/lib/Whoops/Handler/PrettyPageHandler.php'; // Remove developer Mode default behavior ini_set('error_reporting', '-1'); ini_set('display_errors', 'Off'); ini_set('display_startup_errors', 'On'); // Instantiate and register the new handler $run = new Whoops\Run(); $handler = new Whoops\Handler\PrettyPageHandler(); $handler->setResourcesPath(MAGENTO_ROOT . '/lib/Whoops/Resources/'); $run->pushHandler($handler); $run->register();