Ejemplo n.º 1
0
 /**
  * @dataProvider providerTestThrowIfIsNotThrowable
  * @param $value
  * @param bool $throwable
  */
 public function testThrowIfIsNotThrowable($value, $throwable)
 {
     if (!$throwable) {
         $this->setExpectedException('ErrorDumper\\Helpers\\NotThrowableException');
     }
     $exceptions = new Exceptions();
     $exceptions->throwIfIsNotThrowable($value);
 }
Ejemplo n.º 2
0
 public function displayException($exception)
 {
     $exceptions = new Exceptions();
     $exceptions->throwIfIsNotThrowable($exception);
     $vars = array('exception' => $exception, 'exceptionClass' => get_class($exception), 'message' => $exception->getMessage(), 'trace' => array(), '__static' => array('css' => array($this->bootstrapCss), 'js' => array($this->jqueryJs, $this->bootstrapJs)));
     $helper = new HtmlHelper($this->varDumpFn, $this->editor);
     $vars['trace'][] = $helper->prepareStep(array('file' => $exception->getFile(), 'line' => $exception->getLine()));
     foreach ($exception->getTrace() as $rawStep) {
         $vars['trace'][] = $helper->prepareStep($rawStep);
     }
     $template = new Template();
     fputs($this->outputStream, $template->render('exceptions/html', $vars));
 }
Ejemplo n.º 3
0
 public function displayException($exception)
 {
     $exceptions = new Exceptions();
     $exceptions->throwIfIsNotThrowable($exception);
     $width = $this->getWindowWidth();
     $this->printer->defaultBox('');
     $this->printer->defaultBox('');
     $this->printer->errorBox(str_pad('', $width, '#'));
     $this->printer->errorBox(get_class($exception) . ': ' . $exception->getMessage());
     $this->printer->errorBox(str_pad('', $width, '#'));
     $this->printer->defaultBox('');
     $this->printer->defaultBox('');
     $this->printer->defaultBox($exception->getTraceAsString());
 }
Ejemplo n.º 4
0
 /**
  * @param $exception
  * @param Editors\EditorInterface|null $editor
  * @param DumpFunctionInterface $varDumper
  * @return string
  * @throws Helpers\NotThrowableException
  */
 public static function exportExceptionToLightHtml($exception, Editors\EditorInterface $editor = null, DumpFunctionInterface $varDumper = null)
 {
     $exceptions = new Exceptions();
     $exceptions->throwIfIsNotThrowable($exception);
     is_null($editor) && ($editor = new Editors\Nothing());
     $tmp = tmpfile();
     $dumper = new Dumpers\Html($editor, $tmp);
     if (is_null($varDumper)) {
         $varDumper = new LightVarDumper();
     }
     $dumper->setVarDumpFn($varDumper);
     $dumper->displayException($exception);
     $stream = new Stream($tmp);
     $result = $stream->getContents();
     fclose($tmp);
     return $result;
 }
Ejemplo n.º 5
0
 /**
  * @param \Exception|\Throwable $exception
  */
 public function __invoke($exception)
 {
     $exceptions = new Exceptions();
     $exceptions->throwIfIsNotThrowable($exception);
     $pre = $this->preCallback;
     if (!empty($pre)) {
         try {
             call_user_func($pre, $exception);
         } catch (StopDisplayException $stopE) {
             return;
         }
     }
     $this->dumper->displayException($exception);
     $post = $this->postCallback;
     if (!empty($post)) {
         call_user_func($post, $exception);
     }
 }
 /**
  * This method is public because of supporting php 5.3.
  * @param $exception
  */
 public function onError($exception)
 {
     $exceptions = new Exceptions();
     $exceptions->throwIfIsNotThrowable($exception);
     call_user_func($this->callable, $exception);
 }