Esempio n. 1
1
 /**
  * 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);
 }
Esempio n. 2
0
 /**
  * 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());
 }
Esempio n. 3
0
 /**
  * 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);
     }
 }
 /**
  * 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());
 }
 /**
  * @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;
     }
 }
Esempio n. 7
0
 /**
  * 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;
 }
Esempio n. 8
0
 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();
     }
 }
Esempio n. 9
0
});
// 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'));
Esempio n. 10
0
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();
            if ($e['type'] === E_ERROR) {
Esempio n. 11
0
File: boot.php Progetto: moxi9/unity
<?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/');
Esempio n. 12
0
    } 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);
}
Esempio n. 13
0
<?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}';
}