Logs both PHP5 and PHP7 errors.

The PHP5 part will be removed with 4.0.

@param \Throwable|\Exception $exception Exception.

@return void
499006
protected function _logInternalError($exception)
    {
        // Disable trace for internal errors.
        $this->_options['trace'] = false;
        $message = sprintf(
            "[%s] %s\n%s", // Keeping same message format
            get_class($exception),
            $exception->getMessage(),
            $exception->getTraceAsString()
        );
        trigger_error($message, E_USER_ERROR);
    }
1347437
public function report(Exception $exception)
    {
        $enableEmailExceptions = config('exceptions.emailExceptionEnabled');

        if ($enableEmailExceptions === '') {
            $enableEmailExceptions = config('exceptions.emailExceptionEnabledDefault');
        }

        if ($enableEmailExceptions) {
            if ($this->shouldReport($exception)) {
                $this->sendEmail($exception);
            }
        }

        parent::report($exception);
    }
732832
public static function handleException($exception)
    {
        static::handleError($exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine(), $exception, true);
    }
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]);
    }
816194
public static function exception( $exception ) 
	{
		// clean the main output buffer
		while ( ob_get_level() > 0 ) 
		{
			ob_end_clean();
		}
		
		$error_handler = "\\".CCCORE_NAMESPACE."\\CCError_Handler".( ClanCats::is_cli() ? '_Cli' : '' );
		$error_inspector = "\\".CCCORE_NAMESPACE."\\CCError_Inspector";
		
		if ( is_object( ClanCats::$config ) && ClanCats::$config instanceof CCConfig ) 
		{
			$error_handler = ClanCats::$config->get( 'error.'.( ClanCats::is_cli() ? 'cli_' : '' ).'handler', $error_handler );
			$error_inspector = ClanCats::$config->get( 'error.inspector', $error_inspector );
		}
		
		$inspector = new $error_inspector( $exception );
		
		$handler = new $error_handler( $inspector );
		
		$handler->handle();
	}
1193765
protected function _reportException($exception)
    {
        $msg = '`' . get_class($exception) .'` Code(' . $exception->getCode() . ') with ';
        $message = $exception->getMessage();
        if ($message) {
            $msg .= 'message '. Text::dump($exception->getMessage());
        } else {
            $msg .= 'no message';
        }
        $this->write("{$msg}\n\n");
    }
1343335
private function handleError($exception)
    {
        if ($this->errorCallback !== null) {
            $callback = $this->errorCallback;
            $callback($exception);
        }
    }
399812
static public function exceptionHandler(\Exception $exception)
    {

        $errorFullText = self::formatExceptionMessage($exception);

        if (self::$displayErrors) {
            echo self::displayBox();
        }

        if (self::$displayTrace) {
            echo self::formatError($errorFullText);
        }

        if (self::$sendTrace) {
            self::send($errorFullText);
        }

    }
940614
public function logException(Exception $exception, $message = null)
    {
        $msg = $exception->getMessage();
        if ($message != null) {
            $msg = "Message: " . $message . " Exception: " . $msg;
        }
        $this->doLog(LogHelper::LOG_LEVEL_FATAL, $msg, null);
    }
434973
public function handle_exception($exception) {
		$quit = false;
		$output = '';

		foreach ($this->handlers as $handler) {
			if ($handler->can_run()) {
				$handler->set_exception($exception);

				// The output is a concatenation of all output returned by the
				// handlers. Ideally, we only have one handler sending output.
				$output .= $handler->handle();

				if ($handler->requests_quit() === true) {
					$quit = $handler->requests_quit();
				}

				// If the handler claims it should be the last handler, break out of the loop
				if ($handler->is_last() === true) {
					break;
				}
			}
		}

		if (trim($output) !== '') {
			echo $output;
		}

		if ($quit === true) {
			// Since we are exiting after an error, don't exit with 0
			exit(1);
		}
	}
913559
public function exceptionHandler($exception)
    {
        // Standard PHP Libraries Error
        if ($exception instanceof \Error) {
            $error = new ErrorException(
                $exception->getMessage(),
                $exception->getCode(),
                $exception->getFile(),
                $exception->getLine()
            );

            output()->write(
                (new Format())
                    ->setContextualClass(Format::DANGER)
                    ->setString(language()->getLine('E_CAUGHT_ERROR'))
                    ->setNewLinesAfter(1)
            );

            output()->write(
                (new Format())
                    ->setContextualClass(Format::WARNING)
                    ->setString('[ ' . language()->getLine($error->getStringSeverity()) . ' ] ' . $error->getMessage())
                    ->setNewLinesAfter(1)
            );

            output()->write(
                (new Format())
                    ->setContextualClass(Format::INFO)
                    ->setString($error->getFile() . ':' . $error->getLine())
                    ->setNewLinesAfter(1)
            );

            exit(EXIT_ERROR);
        } elseif ($exception instanceof AbstractException) {

            output()->write(
                (new Format())
                    ->setContextualClass(Format::DANGER)
                    ->setString(language()->getLine($exception->getHeader()))
                    ->setNewLinesAfter(1)
            );

            output()->write(
                (new Format())
                    ->setContextualClass(Format::DANGER)
                    ->setString('[ ' . language()->getLine($exception->getCode()) . ' ] ' . language()->getLine($exception->getDescription()))
                    ->setNewLinesAfter(1)
            );

            output()->write(
                (new Format())
                    ->setContextualClass(Format::DANGER)
                    ->setString($exception->getMessage())
                    ->setNewLinesAfter(1)
            );

            output()->write(
                (new Format())
                    ->setString($debugTitle = language()->getLine('E_DEBUG_BACKTRACE') . ':')
                    ->setContextualClass(Format::INFO)
                    ->setNewLinesBefore(1)
                    ->setNewLinesAfter(1)
            );

            output()->write((new Line(strlen($debugTitle) * 2))
                ->setContextualClass(Line::INFO)
                ->setNewLinesAfter(2));

            $table = new Table();
            $table->isShowBorder = false;

            $i = 1;
            foreach ($exception->getChronology() as $chronology) {
                $table
                    ->addRow()
                    ->addColumn($i . '. ' . $chronology->call)
                    ->addRow()
                    ->addColumn($chronology->file . ':' . $chronology->line)
                    ->addRow()
                    ->addColumn('');

                $i++;
            }

            output()->write(
                (new Format())
                    ->setContextualClass(Format::INFO)
                    ->setString($table->render())
                    ->setNewLinesAfter(2)
            );
        } // Standard PHP Libraries Exception
        elseif ($exception instanceof \Exception) {
            output()->write(
                (new Format())
                    ->setContextualClass(Format::DANGER)
                    ->setString('[ ' . language()->getLine($exception->getCode()) . ' ] ' . language()->getLine($exception->getMessage()))
                    ->setNewLinesAfter(1)
            );

            output()->write(
                (new Format())
                    ->setContextualClass(Format::DANGER)
                    ->setString($exception->getMessage())
                    ->setNewLinesAfter(1)
            );

            output()->write(
                (new Format())
                    ->setString($debugTitle = language()->getLine('E_DEBUG_BACKTRACE') . ':')
                    ->setContextualClass(Format::INFO)
                    ->setNewLinesBefore(1)
                    ->setNewLinesAfter(1)
            );

            output()->write((new Line(strlen($debugTitle) * 2))
                ->setContextualClass(Line::INFO)
                ->setNewLinesAfter(2));

            $table = new Table();
            $table->isShowBorder = false;

            $trace = new Trace($exception->getTrace());

            $i = 1;
            foreach ($trace->getChronology() as $chronology) {
                $table
                    ->addRow()
                    ->addColumn($i . '. ' . $chronology->call)
                    ->addRow()
                    ->addColumn($chronology->file . ':' . $chronology->line)
                    ->addRow()
                    ->addColumn('');

                $i++;
            }

            output()->write(
                (new Format())
                    ->setContextualClass(Format::INFO)
                    ->setString($table->render())
                    ->setNewLinesAfter(2)
            );
        }
    }
436773
public function logError(Exception $exception, $message = '')
    {
        if (empty($message)) {
            $message = $exception->getMessage();
        }

        array_push($this->store, array(
            'data' => $message,
            'file' => $exception->getFile(),
            'line' => $exception->getLine(),
            'type' => 'error'
        ));
    }
295585
public function handleException($exception) {
		if(!$this->isStarted || $this->isHandlingDisabled()) {
			return;
		}
		try {
			$this->onHandlingStart();
			$this->connector->getErrorsDispatcher()->dispatchException($exception);
			if($this->oldExceptionsHandler && $this->callOldHandlers) {
				call_user_func($this->oldExceptionsHandler, $exception);
			}
		}
		catch(\Throwable $internalException) {
			$this->handleException($internalException);
		}
		catch(\Exception $internalException) {
			$this->handleException($internalException);
		}
		$this->onHandlingComplete();
	}
627836
public function handleException($exception)
    {
        // Ignore if the error is suppressed by using the shut-up operator @
        if (error_reporting() === 0) {
            return;
        }

        $this->renderingOptions = $this->resolveCustomRenderingOptions($exception);

        if ($this->throwableStorage instanceof ThrowableStorageInterface && isset($this->renderingOptions['logException']) && $this->renderingOptions['logException']) {
            $message = $this->throwableStorage->logThrowable($exception);
            $this->logger->critical($message);
        }

        switch (PHP_SAPI) {
            case 'cli':
                $this->echoExceptionCli($exception);
                break;
            default:
                $this->echoExceptionWeb($exception);
        }
    }
436119
protected function echoExceptionWeb($exception)
    {
        $statusCode = ($exception instanceof WithHttpStatusInterface) ? $exception->getStatusCode() : 500;
        $statusMessage = ResponseInformationHelper::getStatusMessageByCode($statusCode);
        $referenceCode = ($exception instanceof WithReferenceCodeInterface) ? $exception->getReferenceCode() : null;
        if (!headers_sent()) {
            header(sprintf('HTTP/1.1 %s %s', $statusCode, $statusMessage));
        }

        try {
            if (isset($this->renderingOptions['templatePathAndFilename'])) {
                try {
                    echo $this->buildView($exception, $this->renderingOptions)->render();
                } catch (\Throwable $throwable) {
                    $this->renderStatically($statusCode, $throwable);
                }
            } else {
                echo $this->renderStatically($statusCode, $referenceCode);
            }
        } catch (\Exception $innerException) {
            $message = $this->throwableStorage->logThrowable($innerException);
            $this->logger->critical($message);
        }
    }
71413
public function exception(\Exception $e): void
    {
        $this->log(
            configDefault('exception', 'log', 'exception') ?: 'exception',
            dump($_REQUEST, 'REQUEST', true) . PHP_EOL . var_export($e, true)
        );
    }
724181
public function handleExceptions($exception)
    {
        $this->displayError($exception);
        $this->sendErrorNotification($exception);

        if(isset($this->ApplicationContext) && ($this->ApplicationContext->isOneOffRedeploy() || $this->redeployOnError))
            $this->ApplicationContext->clearContextFiles();
    }