Returns the Exception that is the root cause of one or more subsequent exceptions.

@param \Exception $exception The exception of which to find a base exception.

@return \Exception

@see http://bit.ly/16bdp00 <= This is where I found this method
336011
final public static function getBaseException(\Exception $exception)
    {
        while ($exception->getPrevious() !== null) {
            $exception = $exception->getPrevious();
        }

        return $exception;
    }
360110
protected function _code(Exception $exception)
    {
        $code = 500;

        $exception = $this->_unwrap($exception);
        $errorCode = $exception->getCode();
        if ($errorCode >= 400 && $errorCode < 600) {
            $code = $errorCode;
        }

        return $code;
    }
38685
public function logException(\Exception $exception, $prefix = "Exception thrown")
    {
        $class = new \ReflectionClass($exception);
        $this->logger->critical("$prefix [{$class->getName()}] {$exception->getMessage()} on line {$exception->getLine()} of {$exception->getFile()}\n");
        $this->logger->debug("Debug trace for exception: {$exception->getTraceAsString()}");
    }
10399
private function normalizeException(\Exception $exception) {
		$data = [
			'class'   => get_class($exception),
			'message' => $exception->getMessage(),
			'code'    => $exception->getCode(),
			'file'    => $exception->getFile() . ':' . $exception->getLine(),
		];
		$trace = $exception->getTraceAsString();
		$data['trace'] = $trace;

		$previous = $exception->getPrevious();
		if ($previous) {
			$data['previous'] = $this->normalizeException($previous);
		}

		return $data;
	}
135183
public function identify(Exception $exception)
    {
        $hash = spl_object_hash($exception);

        // if we know about the exception, return it's id
        if (isset($this->identification[$hash])) {
            return $this->identification[$hash];
        }

        // cleanup in preparation for the identification
        if (count($this->identification) >= 16) {
            array_shift($this->identification);
        }

        // generate, store, and return the id
        return $this->identification[$hash] = $this->generate();
    }
886013
protected function displayException($exception)
	{
		$displayer = $this->debug ? $this->debugDisplayer : $this->plainDisplayer;

		return $displayer->display($exception);
	}
882355
protected function getClass(\Exception $exception)
    {
        $message = '';

        if (($previous = $exception->getPrevious())) {
            $message = $this->getClass($previous) . ' < '; // Recurse
        }

        // Let the exception lie about its class: to support marshalling exceptions
        if (method_exists($exception, 'getClass')) {
            $message .= $exception->getClass();
        } else {
            $message .= get_class($exception);
        }

        return $message;
    }
595868
protected function formatException(\Exception $exception)
    {
        if (!$this->pythonLike) {
            $s = (string) $exception;
            if (substr($s, -1) == "\n") {
                $s = substr($s, 0, -1);
            }
            return $s;
        }

        $s      = "Traceback (most recent call last):\n";
        $traces = array();
        foreach ($exception->getTrace() as $trace) {
            $origin = '';
            if (isset($trace['class'])) {
                $origin = $trace['class'].$trace['type'];
            }
            if (isset($trace['function'])) {
                $origin .= $trace['function'].'()';
            }
            if ($origin == '') {
                $origin = '???';
            }
            $file = isset($trace['file']) ? $trace['file'] : '{main}';
            $line = isset($trace['line']) ? $trace['line'] : 0;
            $traces[] = "File \"$file\", line $line, in $origin";
        }
        $s .= implode("\n", array_reverse($traces))."\n";
        $s .=   "Exception '" . get_class($exception) .
                "' with message '" . $exception->getMessage() .
                "' in " . $exception->getFile() .
                ":" . $exception->getLine();
        return $s;
    }
200084
protected function logException(\Exception $exception)
    {
        if (!$exception instanceof \OxidEsales\Eshop\Core\Exception\StandardException) {
            $exception = new \OxidEsales\Eshop\Core\Exception\StandardException($exception->getMessage(), $exception->getCode(), $exception);
        }
        \OxidEsales\Eshop\Core\Registry::getLogger()->error($exception->getMessage(), [$exception]);
    }
846589
protected function getStatusCode(Exception $exception)
    {
        if ($exception instanceof ValidationException) {
            return $exception->status;
        }

        return $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : 500;
    }
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 ();
		
	}
31983
public function exceptionHandler($exception)
    {
        $this->lastHandledException = $exception;

        $this->client->catchException($exception);

        if ($this->oldExceptionHandler) {
            call_user_func(
                $this->oldExceptionHandler,
                $exception
            );
        }
    }
137327
public static function exception(ApiException $exception)
    {
        $returnResponse = \Response::make($exception->jsonSerialize());

        $returnResponse->setStatusCode($exception->getStatusCode());

        return $returnResponse;
    }
453746
public function getBacktrace($exception = null)
    {
        $skipLimit = false;

        if ($exception instanceof \Exception || $exception instanceof \Throwable) {
            $backtrace = $exception->getTrace();
            foreach ($backtrace as $index => $backtraceCall) {
                unset($backtrace[$index]['args']);
            }
        } elseif (version_compare(PHP_VERSION, '5.4.0') >= 0) {
            $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $this->backtraceLimit);
            $skipLimit = true;
        } else {
            $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
        }

        if ($this->backtraceLimit > 0 && !$skipLimit) {
            $backtrace = array_slice($backtrace, 0, $this->backtraceLimit);
        }

        return $backtrace;
    }
936616
public function transform(Exception $exception)
    {
        if ($exception instanceof ModelNotFoundException) {
            $exception = new NotFoundHttpException($exception->getMessage(), $exception, $exception->getCode());
        }

        return $exception;
    }
1206785
public static function onException( $exception )
    {
        $_trace = $exception->getTrace();
        $_traceText = static::_cleanTrace( $_trace, 3 );

        if ( E_NOTICE == $exception->getCode() )
        {
            return false;
        }

        static::$_error = array(
            'code'       => $exception->getCode(),
            'type'       => '',
            'message'    => $exception->getMessage(),
            'file'       => $exception->getFile(),
            'line'       => $exception->getLine(),
            'trace'      => $_traceText,
            'traces'     => $exception->getTrace(),
            'source'     => static::_getCodeLines( $exception->getFile(), $exception->getLine(), static::$_sourceLines ),
            'start_line' => static::$_startLine,
        );

        Log::error( static::$_error['message'] . ' (' . static::$_error['code'] . ')' );

        return static::renderError();
    }
273036
private static function _formatException($exception)
    {
        return str_replace(realpath(BASE_PATH), '', \Mmi\App\FrontController::getInstance()->getEnvironment()->requestUri . ' (' . $exception->getMessage() . ') @' .
            $exception->getFile() . '(' . $exception->getLine() . ') ' .
            self::_formatTrace($exception));
    }