Echoes previous exceptions if applicable

@author Art <a.molcanovas@gmail.com>

@param null|\Throwable $e     The previous exception
@param int             $level How many previous exceptions have been echoed so far

@codeCoverageIgnore
340347
protected function echoPreviousExceptions($e, $level = 0) {
            if ($level < $this->config->prevExceptionDepth && $e) {
                if ($this->isCLI) {
                    $this->console->write('<eb>Preceded by </>')
                                  ->write('<e>[' . $e->getCode() . '] ' . $e->getMessage() . '</>')
                                  ->write('<e> @ ' . $e->getFile() . '\'s line ' . $e->getLine() . '</>', true)
                                  ->writeln('');
                } else {
                    ?>
                    <div>
                        <span class="alo-bold">Preceded by </span>
                        <span>[<?= $e->getCode() ?>]: <?= $e->getMessage() ?></span>
                        <span> @ </span>
                        <span class="alo-uline"><?= $e->getFile() ?></span>
                        <span> @ line </span>
                        <span class="alo-uline"><?= $e->getLine() ?>
                    </div>
                    <?php
                }

                $this->echoPreviousExceptions($e->getPrevious(), ++$level);
            }
        }
889952
private function _failOnErrorAction(Exception $exception = null, $message = '', $level = Project::MSG_INFO)
    {
        if ($this->_failonerror) {
            throw new BuildException(
                $exception !== null ? $exception : $message,
                $this->getLocation()
            );
        } else {
            $this->log(
                $exception !== null && $message === '' ? $exception->getMessage() : $message,
                $level
            );
        }
    }
1093447
static function Start($level = null)
	{
		
		if ($level == null) 
		{
			if (defined("E_DEPRECATED"))
			{
				$level = E_ALL & ~E_DEPRECATED ;
			}
			else
			{
				// php 5.2 and earlier don't support E_DEPRECATED
				$level = E_ALL;
				self::$IGNORE_DEPRECATED = true;
			}
		}
		set_error_handler(array("ExceptionThrower", "HandleError"), $level);
	}
205993
@Deprecated
  public static void reportException(final Throwable throwable, final String level) {
    reportException(throwable, level, null, null);
  }
64344
public function writeException(Exception $e)
    {
        $class = get_class($e);
        $text = $this->adapter->colorize("Exception - $class:\n{$e->getMessage()}\n", ColorInterface::LIGHT_RED);

        if ($this->isVerbose()) {
            $text .= "\n" . $this->renderTrace($e->getTrace()) . "\n";

            if ($this->isVeryVerbose() && ($previous = $e->getPrevious())) {
                $text .= "\n" . $this->adapter->colorize('Previous Exceptions:', ColorInterface::YELLOW) . "\n\n";

                do {
                    $class = $this->adapter->colorize(get_class($previous), ColorInterface::YELLOW);
                    $msg = $this->adapter->colorize($previous->getMessage(), ColorInterface::GRAY);
                    $text .= sprintf('%s: %s', $class, $msg)
                           . "\n" . $this->renderTrace($e->getTrace()) . "\n\n";
                } while ($previous = $previous->getPrevious());
            }
        }

        $this->adapter->writeLine($text);
    }
1374749
private function log($message, $level)
    {
        // Only log if the logger is enabled.
        if (!$this->isEnabled) {
            return;
        }

        if ($level <= $this->level) {
            $requestId = null;
            try {
                $requestID = Application::getCurrent()->getRequestId();
            } catch (CoreException $exception) {
                $requestID = '---';
            }

            $logMessage = sprintf(
                '%s: %s [%s] %s' . PHP_EOL,
                $this->id,
                $requestId ?: '———',
                @self::$levelNames[$level],
                $message
            );

            // Commit the log message.
            if (empty($this->errorLogFile)) {
                // If no log file is specified, use the default PHP location.
                error_log($logMessage);
            } else {
                // Silence the eventual error if the message cannot be written
                // to the log, so that it doesn't interrupt the program.
                @file_put_contents(
                    $this->errorLogFile,
                    $logMessage,
                    FILE_APPEND
                );
            }
        }
    }
456858
public function log($message, $level = 0) {
        foreach ($this->_loggers as $logger) {
            try {
                $logger->logMessage($message, $level);
            } catch (LoggerException $e) {
                throw $e;
            }
        }
    }
897269
private function _haltOnErrorAction(Exception $exception = null, $message = '', $level = Project::MSG_INFO)
    {
        if ($this->_haltonerror) {
            throw new BuildException(
                $exception !== null ? $exception : $message,
                $this->getLocation()
            );
        } else {
            $this->log(
                $exception !== null && $message === '' ? $exception->getMessage() : $message,
                $level
            );
        }

    }
857724
public function report(Exception $e)
    {
        if ($this->shouldntReport($e)) {
            return;
        }

        try {
            if ($this->plugin->bound('bugsnag.multi')) {
                $logger = $this->plugin->make('bugsnag.multi');
            } else {            
                $logger = $this->plugin->make('Psr\Log\LoggerInterface');
            }
            $logger->error($e);

        } catch (Exception $ex) {
            throw $e; // throw the original exception
        } finally {
            $this->renderException($e);
        }
    }
1231070
public function throwAt($levels, $replace = false)
    {
        $prev = $this->thrownErrors;
        $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
        if (!$replace) {
            $this->thrownErrors |= $prev;
        }
        $this->reRegister($prev | $this->loggedErrors);

        return $prev;
    }
814512
protected function handleError(Exception $e)
    {
        if($this->isCli){
            $errorCode = $e->getCode();
            exit((empty($errorCode)) ? 1 : $errorCode);	//exit the program with an error
        }
        else {
            throw new Exception($e->getMessage());
        }
    }
816918
private function logException(\Exception $e)
    {
        if (isset($this->logger)) {
            $this->logger->notice(
                $e->getMessage(), [
                                    'code' => $e->getCode(),
                                    'line' => $e->getLine(),
                                    'file' => $e->getFile(),
                                ]
            );
        } else {
            // @codeCoverageIgnoreStart
            error_log(sprintf('[%s] [%s:%d] %s', $e->getCode(), $e->getFile(), $e->getLine(), $e->getMessage()), E_NOTICE);
            // @codeCoverageIgnoreEnd
        }
    }
1303570
protected function handleException(Exception $e)
    {
        $handler = $this->app->make(ExceptionHandler::class);

        $handler->report($e);

        try {
            $handler->renderForConsole(
                $this->app->make(OutputInterface::class), $e
            );
        } catch (Throwable $e) {
            //
        }
    }
700373
public function retry_incremental(\Exception $e = null, $output = null, $exp = 2, $unit = 'minutes') {
		if (self::$max_attempts > 0 AND $this->retry_attempt >= self::$max_attempts) {
			echo $output;
			throw $e;
		}

		$this->retry_attempt++;
		$this->schedule(pow($this->retry_attempt, $exp) . ' ' . $unit);
	}
1119295
public function handle(\Exception $e) {

		try {
			ob_clean();
			$this->createResponse($e)->send();
		}
		
		catch(\Exception $e) {
			printf('Exception thrown when handling exception (%s: %s)', get_class($e), $e->getMessage());
			exit();
		}

	}
256066
public static function handle($level, $message, $file, $line)
    {
        // respect error_reporting being disabled
        if (0 === error_reporting()) {
            return;
        }

        if (ini_get('xdebug.scream')) {
            $message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be" .
            "\na legitimately suppressed error that you were not supposed to see.";
        }

        throw new ErrorException($message, 0, $level, $file, $line);
    }
214340
private function _error($message, $level = E_USER_NOTICE)
	{
		$caller = next(debug_backtrace());

		switch ($level)
		{
			case E_USER_NOTICE:
				echo "Notice: ";
				break;
			case E_USER_ERROR:
				echo "Fatal error: ";
				break;
			default:
				echo "Unknown error: ";
				break;
		}

		echo $message . ' in ' . $caller['file'] . ' on line ' . $caller['line'] . "\n";
	}