Example #1
0
 /**
  * Outputs a stack trace based on the supplied options.
  *
  * ### Options
  *
  * - `depth` - The number of stack frames to return. Defaults to 50
  * - `start` - The stack frame to start generating a trace from. Defaults to 1
  *
  * @param array $options Format for outputting stack trace
  * @return mixed Formatted stack trace
  * @link https://github.com/cakephp/cakephp/blob/master/src/basics.php
  */
 function stackTrace(array $options = array())
 {
     if (!WP_DEBUG) {
         return;
     }
     $defaults = array('start' => 0);
     if (Strata::isBundledServer() || Strata::isCommandLineInterface()) {
         $defaults['output'] = Debugger::CONSOLE;
     }
     $options += $defaults;
     $options['start']++;
     $trace = Debugger::trace(null, $options);
     if (Strata::isBundledServer()) {
         Strata::app()->getLogger("StrataConsole")->debug("\n\n" . $trace . "\n\n");
     }
     if (Strata::isCommandLineInterface()) {
         echo "\n\n" . $trace . "\n\n";
     } else {
         echo "<div style=\"" . Debugger::HTML_STYLES . "\"><pre>" . $trace . "</pre></div>";
     }
 }
 /**
  * Handle uncaught exceptions.
  *
  * Uses a template method provided by subclasses to display errors in an
  * environment appropriate way.
  *
  * @param \Exception $exception Exception instance.
  * @return void
  * @throws \Exception When renderer class not found
  * @see http://php.net/manual/en/function.set-exception-handler.php
  */
 public function handleException($exception)
 {
     if (!$this->canCatchTheError($exception->getFile())) {
         return;
     }
     $data = array('type' => "Exception", 'code' => $exception->getCode(), 'description' => $exception->getMessage(), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'context' => null, 'trace' => Debugger::trace($exception->getTrace()));
     $this->displayExceptionData($data);
     $this->logExceptionData($data);
     $this->endProcesses();
 }