]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Special/HTTPException.php
Remove fallback contact query from Model\Contact::photoMenu
[friendica.git] / src / Module / Special / HTTPException.php
index 3b771c3ac7d5bc7b8c2ef426e1e3873e73b94469..0cd7817ed4de05017a3156d0e98d5ecb1805c7a8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -65,16 +65,25 @@ class HTTPException
         * @param \Friendica\Network\HTTPException $e
         * @throws \Exception
         */
-       public static function rawContent(\Friendica\Network\HTTPException $e)
+       public function rawContent(\Friendica\Network\HTTPException $e)
        {
                $content = '';
 
                if ($e->getCode() >= 400) {
-                       $tpl = Renderer::getMarkupTemplate('http_status.tpl');
-                       $content = Renderer::replaceMacros($tpl, self::getVars($e));
+                       $vars = self::getVars($e);
+                       try {
+                               $tpl = Renderer::getMarkupTemplate('http_status.tpl');
+                               $content = Renderer::replaceMacros($tpl, $vars);
+                       } catch (\Exception $e) {
+                               $content = "<h1>{$vars['$title']}</h1><p>{$vars['$message']}</p>";
+                               if (DI::app()->isSiteAdmin()) {
+                                       $content .= "<p>{$vars['$thrown']}</p>";
+                                       $content .= "<pre>{$vars['$trace']}</pre>";
+                               }
+                       }
                }
 
-               System::httpExit($e->getCode(), $e->getDescription(), $content);
+               System::httpError($e->getCode(), $e->getDescription(), $content);
        }
 
        /**
@@ -84,12 +93,12 @@ class HTTPException
         * @return string
         * @throws \Exception
         */
-       public static function content(\Friendica\Network\HTTPException $e)
+       public function content(\Friendica\Network\HTTPException $e): string
        {
                header($_SERVER["SERVER_PROTOCOL"] . ' ' . $e->getCode() . ' ' . $e->getDescription());
 
                if ($e->getCode() >= 400) {
-                       Logger::debug('Exit with error', ['code' => $e->getCode(), 'description' => $e->getDescription(), 'query' => DI::args()->getQueryString(), 'callstack' => System::callstack(20), 'method' => $_SERVER['REQUEST_METHOD'], 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
+                       Logger::debug('Exit with error', ['code' => $e->getCode(), 'description' => $e->getDescription(), 'query' => DI::args()->getQueryString(), 'callstack' => System::callstack(20), 'method' => DI::args()->getMethod(), 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '']);
                }
 
                $tpl = Renderer::getMarkupTemplate('exception.tpl');