Write to the error log if displayErrorDetails is false

@param \Exception|\Throwable $throwable

@return void
496882
protected function writeToErrorLog($throwable) {
		$message = 'Wiggum Application Error:' . PHP_EOL;
	
		$message .= $this->renderErrorAsText($throwable);
		while ($throwable = $throwable->getPrevious()) {
			$message .= PHP_EOL . 'Previous error:' . PHP_EOL;
			$message .= $this->renderErrorAsText($throwable);
		}
	
		$this->logError($message);
	}
47147
private function shouldBeLogged(Throwable $throwable): bool
    {
        $result = array_key_exists(get_class($throwable), $this->doNotLogClassesAsKeys) === false;

        return $result;
    }
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);
        }
    }
371141
private function logError(Throwable $throwable, string $message): void
    {
        if ($this->logger !== null && $this->shouldBeLogged($throwable) === true) {
            // on error (e.g. no permission to write on disk or etc) ignore
            try {
                $this->logger->error($message, ['error' => $throwable]);
            } catch (Exception $exception) {
            }
        }
    }
436822
public function handle($throwable)
    {
        if ($throwable instanceof Exception) {
            $response = $this->handler->handleException($this->defaultRequest, $this->defaultResponse, $throwable);
        } elseif ($throwable instanceof Throwable) {
            $response = $this->handler->handleThrowable($this->defaultRequest, $this->defaultResponse, $throwable);
        } else {
            return false;
        }

        if ($response instanceof ResponseInterface) {
            $this->renderResponse($response);
            return true;
        } else {
            return false;
        }
    }
278340
public static void debug(final Throwable throwable) {
        final StringWriter errors = new StringWriter();
        throwable.printStackTrace(new PrintWriter(errors));
        debugLogger.accept(errors.toString());
    }
395753
public static function exceptionHandler(\Throwable $exception, bool $exit = true): void
    {
        if (!self::$reserved && $exit) {
            return;
        }
        self::$reserved = null;

        Helpers::improveException($exception);
        self::removeOutputBuffers(true);

        if (self::isProductionMode()) {
            try {
                self::log($exception, self::getExceptionLevel($exception));
            } catch (\Throwable $e) {
            }

            $message = 'ERROR: application encountered an error and can not continue. '
                . (isset($e) ? "Unable to log error.\n" : "Error was logged.\n");

            if (PHP_SAPI === 'cli') {
                \fwrite(STDERR, $message);
            } else {
                echo $message;
            }
        } else {
            $level = self::getExceptionLevel($exception);
            self::chromeLog($exception, $level);

            try {
                $file = self::log($exception, $level);

                echo "$exception\n" . ($file ? "(stored in $file)\n" : '');
                if ($file && PHP_SAPI === 'cli') {
                    if (self::$browser) {
                        \exec(self::$browser . ' ' . \escapeshellarg($file));
                    } elseif (DIRECTORY_SEPARATOR === '\\') {
                        \exec(\escapeshellarg($file));
                    } elseif (strtoupper(PHP_OS) === 'DARWIN') {
                        \exec('open ' . \escapeshellarg($file));
                    }
                }
            } catch (\Throwable $e) {
                echo "$exception\nUnable to log error: {$e->getMessage()}\n";
            }
        }

        if ($exit) {
            exit(255);
        }
    }
1045387
private function withError(ResponseInterface $response, $throwable)
    {
        if ($throwable instanceof ErrorException) {
            $severity = ErrorHandler::getErrorType($throwable->getSeverity());
        } else {
            $severity = 'Error';
        }

        $contents = [
            'message' => 'Application Error',
            'status' => 500,
            'severity' => $severity,
            'throwable' => $throwable,
        ];

        if ($this->displayErrorDetails) {
            $throwables = $this->unpackThrowables($throwable);
            $contents['details'] = $this->formatStacktraceForExceptions($throwables);
            $contents['message'] = $throwable->getMessage();
        }

        return $this
            ->withHTML($response, $contents)
            ->withStatus(500);
    }
935895
protected function fail(\Throwable $error): void
    {
        if (~$this->state & AbstractPromise::PENDING) {
            return;
        }
        
        $callbacks = $this->result;
        
        $this->state ^= AbstractPromise::PENDING | AbstractPromise::FAILED;
        $this->result = $error;
        
        if ($this instanceof Cancellable) {
            $this->context->unregisterCancellation($this);
        }
        
        if ($callbacks) {
            if (\is_array($callbacks)) {
                foreach ($callbacks as $callback) {
                    try {
                        $callback($error);
                    } catch (\Throwable $e) {
                        $this->context->handleError($e);
                    }
                }
            } else {
                try {
                    $callbacks($error);
                } catch (\Throwable $e) {
                    $this->context->handleError($e);
                }
            }
        }
    }
850232
public function exceptionHandler( Exception $exception, $display = true )
    {
        if ( $this->serviceLocator &&
             $this->serviceLocator instanceof ServiceLocatorInterface &&
             $this->serviceLocator->has( 'Zork\Log\LoggerManager' ) )
        {
            try
            {
                /* @var $loggerManager \Zork\Log\LoggerManager */
                $loggerManager = $this->serviceLocator->get( 'Zork\Log\LoggerManager' );

                if ( $loggerManager->hasLogger( 'exception' ) )
                {
                    $loggerManager->getLogger( 'exception' )
                                  ->crit( '<pre>' . $exception . '</pre>' . PHP_EOL );
                }
            }
            catch ( Exception $ex )
            {
                // do nothing
            }
        }

        if ( $display )
        {
            if ( PHP_SAPI == 'cli' )
            {
                $write  = (string) $exception;
                $stderr = @ fopen( 'php://stderr', 'a' );

                if ( is_resource( $stderr ) )
                {
                    fwrite( $stderr, $write );
                    fclose( $stderr );
                }
                else
                {
                    echo $write;
                }
            }
            else
            {
                $status = '500 Internal server error';
                @ header( $_SERVER['SERVER_PROTOCOL'] . ' ' . $status );
                @ header( 'Status: ' . $status );
                @ header( 'Expires: -1' );
                @ header( 'Pragma: no-cache' );
                @ header( 'Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0' );
                @ header( 'Connection: close' );
                @ header( 'Content-type: text/html; charset=utf-8' );
                include __DIR__ . '/view/error/500.phtml';
            }
        }
    }
134646
protected function renderHtmlError($throwable)
    {
        $code    = $throwable->getCode();
        $message = $throwable->getMessage();
        $file    = $throwable->getFile();
        $line    = $throwable->getLine();
        $trace   = $throwable->getTraceAsString();

        $html = sprintf('<div><strong>Type:</strong> %s</div>', get_class($throwable));

        if ($code) {
            $html .= sprintf('<div><strong>Code:</strong> %s</div>', $code);
        }

        if ($message) {
            $html .= sprintf('<div><strong>Message:</strong> %s</div>', htmlentities($message));
        }

        if ($file) {
            $html .= sprintf('<div><strong>File:</strong> %s</div>', $file);
        }

        if ($line) {
            $html .= sprintf('<div><strong>Line:</strong> %s</div>', $line);
        }

        if ($trace) {
            $html .= '<h2>'.$this->translator()->translate('Trace', [], 'charcoal').'</h2>';
            $html .= sprintf('<pre>%s</pre>', htmlentities($trace));
        }

        return $html;
    }
925908
static function render(\Throwable $exception, bool $renderTrace = true, bool $renderPrevious = false): string
    {
        $exceptions = $renderPrevious ? static::getChain($exception) : [$exception];
        $totalExceptions = count($exceptions);
        $lastException = $totalExceptions - 1;

        $output = '';
        for ($i = 0; $i < $totalExceptions; ++$i) {
            if ($i > 0 && $renderTrace) {
                $output .= "\n";
            }

            $output .= ($renderPrevious ? '[' . ($i + 1) . "/{$totalExceptions}] " : '')
                . static::getName($exceptions[$i])
                . ': ' . ($exceptions[$i]->getMessage() ?: '<no message>')
                . " in {$exceptions[$i]->getFile()} on line {$exceptions[$i]->getLine()}";

            if ($renderTrace || $i < $lastException) {
                $output .= "\n";
            }

            if ($renderTrace) {
                $output .= $exceptions[$i]->getTraceAsString();

                if ($i < $lastException) {
                    $output .= "\n";
                }
            }
        }

        return $output;
    }
1175614
protected function renderXmlMessage($throwable)
    {
        $xml = "<error>\n  <message>".$this->getSummary()."</message>\n";
        if ($this->displayErrorDetails()) {
            do {
                $xml .= "  <exception>\n";
                $xml .= '    <type>'.get_class($throwable)."</type>\n";
                $xml .= '    <code>'.$throwable->getCode()."</code>\n";
                $xml .= '    <message>'.$this->createCdataSection($throwable->getMessage())."</message>\n";
                $xml .= '    <file>'.$throwable->getFile()."</file>\n";
                $xml .= '    <line>'.$throwable->getLine()."</line>\n";
                $xml .= '    <trace>'.$this->createCdataSection($throwable->getTraceAsString())."</trace>\n";
                $xml .= "  </exception>\n";
            } while ($throwable = $throwable->getPrevious());
        }
        $xml .= '</error>';

        return $xml;
    }
1322772
private function handleThrowtable(\Throwable $throwable)
    {
        $message = sprintf("%s %s %d", $throwable->getFile(), $throwable->getMessage(), $throwable->getLine());

        /* @var \Swoft\Http\Message\Server\Response $response */
        $response = RequestContext::getResponse();
        $response = $response->json([$message]);

        return $response;
    }
1218992
protected function echoExceptionCli(\Throwable $exception)
    {
        $response = new CliResponse();

        $exceptionMessage = $this->renderSingleExceptionCli($exception);
        $exceptionMessage = $this->renderNestedExceptonsCli($exception, $exceptionMessage);

        if ($exception instanceof FlowException) {
            $exceptionMessage .= PHP_EOL . 'Open <b>Data/Logs/Exceptions/' . $exception->getReferenceCode() . '.txt</b> for a full stack trace.' . PHP_EOL;
        }

        $response->setContent($exceptionMessage);
        $response->send();
        exit(1);
    }
392234
public function handleException(\Throwable $throwable)
    {
        // Captured an application-level exception.
        try {
            // Log the exception.
            Logger::get()->exception($throwable);
            // Try to display a user-friendly message.
            $responder = new Responders\Http\Error;
            $responder->setThrowable($throwable);
            $responder->getResponse()->issue();
            // Stop the application, as it did not handle the exception
            // properly.
            die(-1);
        } catch (\Exception $innerException) {
            $this->fail($innerException);
        }
    }
279615
public function exceptionHandler(\Throwable $exception)
    {
        \BFW\Application::getInstance()
            ->getMonolog()
            ->getLogger()
            ->debug(
                'New exception catched.',
                [
                    'msg'  => $exception->getMessage(),
                    'file' => $exception->getFile(),
                    'line' => $exception->getLine()
                ]
            );
        
        $errorRender = $this->obtainExceptionRender();
        
        $this->callRender(
            $errorRender,
            'Exception Uncaught', 
            $exception->getMessage(), 
            $exception->getFile(), 
            $exception->getLine(), 
            $exception->getTrace(),
            $exception->getCode()
        );
    }