Render exception for debugging.

@param   \Exception $exception The exception we want to render.

@return  void

@since   2.0
168640
public function renderException(\Exception $exception)
    {
        $verbose = $this->console ? $this->console->get('verbose', 0) : 0;

        if (!$verbose) {
            $this->out()->err($exception->getMessage());

            return;
        }

        /** @var $exception \Exception */
        $class = get_class($exception);

        // @codingStandardsIgnoreStart
        $output = <<<EOF
<error>Exception '{$class}' with message:</error> <fg=cyan;options=bold>{$exception->getMessage()}</fg=cyan;options=bold>
<info>in {$exception->getFile()}:{$exception->getLine()}</info>

<error>Stack trace:</error>
{$exception->getTraceAsString()}
EOF;
        // @codingStandardsIgnoreEnd

        $this->out('');
        $this->err($output);
    }
1247108
public function catchException($exception)
    {
        if (in_array(get_class($exception), $this->config->getExcludeExceptions())) {
            return;
        }

        try {
            $this->send(
                Formatter::make($exception, $this->config)->toArray()
            );
        } catch (Exception $exception) {
            error_log('AfterBug Error: Couldn\'t notify. '.$exception->getMessage());
        }
    }
639434
static public function exceptionHandler($exception)
    {
        $msg = $exception->getMessage()
                . " Line "
                . $exception->getLine()
                . ", "
                . $exception->getFile();
        self::$logger->debug($msg);
    }
737887
public function renderForConsole($output, Exception $e)
    {
        if ($this->exceptionHandler !== null) {
            $this->exceptionHandler->renderForConsole($output, $e);
        }
    }
522383
public function render($exception)
    {
        for ($level = ob_get_level(); $level > 0; $level--) {
            ob_end_clean();
        }

        if ($this->configure->debug) {
            if ($this->renderer->exists('@views/Errors/debug')) {
                return $this->renderer->render('@views/Errors/debug', ['exception' => $exception]);
            } else {
                return $this->renderer->render('@manaphp/Mvc/ErrorHandler/Views/debug', ['exception' => $exception]);
            }
        }

        $statusCode = $exception instanceof \ManaPHP\Exception ? $exception->getStatusCode() : 500;

        foreach (["@views/Errors/$statusCode",
                     '@views/Errors/error'] as $template) {
            if ($this->renderer->exists($template)) {
                return $this->renderer->render($template, ['statusCode' => $statusCode, 'exception' => $exception]);
            }
        }
        $status = $this->response->getStatus();
        return "<html lang='en'><title>$status</title><body>$status</body></html>";
    }
53351
public static function renderException(\Exception $exception)
    {
        $error = new MessageBag([
            'type'    => get_class($exception),
            'message' => $exception->getMessage(),
            'file'    => $exception->getFile(),
            'line'    => $exception->getLine(),
            'trace'   => $exception->getTraceAsString(),
        ]);

        $errors = new ViewErrorBag();
        $errors->put('exception', $error);

        return view('admin::partials.exception', compact('errors'))->render();
    }
522131
protected function renderException($exception)
  {
    if ($this->myDebug)
    {
      if ($exception instanceof ErrorException)
      {
        $message = $exception->getName();
      }
      elseif ($exception instanceof NamedException)
      {
        $message = "Exception ({$exception->getName()})";
      }
      else
      {
        $message = 'Exception';
      }

      $message .= " '".get_class($exception)."'";
      $message .= ' with message '.$exception->getMessage();
      $message .= "\n\n";
      $message .= "in ".$exception->getFile().':'.$exception->getLine()."\n";
      $message .= "\n";
      $message .= "Stack trace:\n";
      $message .= $exception->getTraceAsString();
    }
    elseif ($exception instanceof NamedException)
    {
      $message = $exception->getName().': '.$exception->getMessage();
    }
    else
    {
      $message = 'Error: '.$exception->getMessage();
    }

    echo $message, "\n";
  }
715121
protected function logException(\Exception $exception)
    {
        $this->logger->error(
            $exception->getMessage(),
            array(
                'class'=>get_class($exception),
                'message'=>$exception->getMessage(),
                'file'=>$exception->getMessage(),
                'line'=>$exception->getMessage(),
                'command'=>$this->getName()
            )
        );
    }
16894
public function render(Exception $e)
    {
        if ($e instanceof HttpResponseException) {
            /* error occurs */
            switch ($e->getCode()) {
                case HttpResponseException::ERR_NOTFOUND_CONTROLLER:
                case HttpResponseException::ERR_NOTFOUND_ACTION:
                case HttpResponseException::ERR_NOTFOUND_VIEW:
                    response()->setStatusCode(404);
                    echo htmlspecialchars($e->getMessage());
                    break;
                default :
                    echo 0, ':', htmlspecialchars($e->getMessage());
                    break;
            }
        } else {
            $this->convertExceptionToResponse($e);
        }
    }
1158057
public function Exception ($exception)
	{
		
		// Clear output buffers
		
		while (ob_get_level ())
		{
			ob_end_clean ();
		}
		
		// Set error
		
		$this->result	= array (
			'status'	=> 'fail',
			'message'	=> 'exception',
			'exception'	=> array (
				'file'		=> $exception->getFile (),
				'line'		=> $exception->getLine (),
				'message'	=> $exception->getMessage ()
			)
		);
		
		// Auditlog
		
		$auditlog	= \Sonic\Sonic::getResource ('auditlog');

		if ($auditlog instanceof Audit\Log)
		{
			$auditlog::_Log ($this->action, 7, $this->args, $this->result['exception']);
		}
		
		// Display
		
		$this->Display ();
		
	}
186956
public function handleException($exception)
  {
    // Disable error capturing to avoid recursive errors while handling exceptions.
    $this->unregister();

    try
    {
      $this->clearOutput();
      $this->renderException($exception);

      exit(-1);
    }
    catch (\Exception $e)
    {
      // Another exception could be thrown while displaying the exception.
      $message = "An Error occurred while handling another error:\n";
      $message .= (string)$e;
      $message .= "\nPrevious exception:\n";
      $message .= (string)$exception;
      if ($this->myDebug)
      {
        $this->echoMessage($message);
      }
      else
      {
        $this->echoMessage('An internal server error occurred.');
      }
      $message .= "\n\$_SERVER = ".print_r($_SERVER, true);
      error_log($message);

      exit(1);
    }
  }
917934
public function render($request, Exception $exception)
    {
        foreach ($this->getHandlers() as $handler) {
            if ($return = $handler->render($request, $exception)) {
                return $return;
            }
        }

        # Search throught all Handler defined in Package
        return parent::render($request, $exception);
    }
934006
protected function renderException($exception)
    {
        if ($exception instanceof Exception && ($exception instanceof UserException || !YII_DEBUG)) {
            $message = $this->formatMessage($exception->getName() . ': ') . $exception->getMessage();
        } elseif (YII_DEBUG) {
            if ($exception instanceof Exception) {
                $message = $this->formatMessage("Exception ({$exception->getName()})");
            } elseif ($exception instanceof ErrorException) {
                $message = $this->formatMessage($exception->getName());
            } else {
                $message = $this->formatMessage('Exception');
            }
            $message .= $this->formatMessage(" '" . get_class($exception) . "'", [Console::BOLD, Console::FG_BLUE])
                . ' with message ' . $this->formatMessage("'{$exception->getMessage()}'", [Console::BOLD]) //. "\n"
                . "\n\nin " . dirname($exception->getFile()) . DIRECTORY_SEPARATOR . $this->formatMessage(basename($exception->getFile()), [Console::BOLD])
                . ':' . $this->formatMessage($exception->getLine(), [Console::BOLD, Console::FG_YELLOW]) . "\n";
            if ($exception instanceof \yii\db\Exception && !empty($exception->errorInfo)) {
                $message .= "\n" . $this->formatMessage("Error Info:\n", [Console::BOLD]) . print_r($exception->errorInfo, true);
            }
            $message .= "\n" . $this->formatMessage("Stack trace:\n", [Console::BOLD]) . $exception->getTraceAsString();
        } else {
            $message = $this->formatMessage('Error: ') . $exception->getMessage();
        }

        if (PHP_SAPI === 'cli') {
            Console::stderr($message . "\n");
        } else {
            echo $message . "\n";
        }
    }
342821
public function render()
    {
        $args = func_get_args();

        foreach ($args as $arg) {
            if(isset($this->output[$arg])) {
                return $this->output[$arg];
            }

            throw new Exception("{$arg} is not set!", 1);
        }
    }
527551
public function handleException(Exception $exception)
    {
        try {
            while (ob_get_level()) {
                ob_end_clean();
            }

            $code = 500;
            if (is_subclass_of($exception, 'Rad\\Core\\Exception\\BaseNetworkException')) {
                $code = $exception->getCode();
            }

            http_response_code($code);
            echo $this->handler->handle($exception);

            return;
        } catch (Exception $e) {
            $message = sprintf(
                "[%s] %s\n%s",
                get_class($e),
                $e->getMessage(),
                $e->getTraceAsString()
            );

            trigger_error($message, E_USER_ERROR);
        }
    }
1201514
protected function handle($exception)
  {
    Output::error($exception);

    if ($this->isAjax()) {
      $this->toJson($exception);
      return;
    }

    $this->toHtml($exception);
  }
274000
public function render($request, Exception $exception)
    {
        if ($exception instanceof TokenExpiredException) {
            return response()->json(['token_expired'], $exception->getCode());
        } else if ($exception instanceof TokenInvalidException) {
            return response()->json(['token_invalid'], $exception->getCode());
        }
        return parent::render($request, $exception);
    }