From c684d0a2cd076a7bed8602aff94e125a5cd671db Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Wed, 2 Apr 2025 23:59:43 +0530 Subject: [PATCH] Enhance error pages --- app/controllers/general.php | 2 +- app/views/general/error.phtml | 402 ++++++++++++++++++++++++++-------- 2 files changed, 316 insertions(+), 88 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 5ce0a03471..f4d973dc19 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -83,7 +83,7 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw } if (\str_ends_with($host, System::getEnv('_APP_DOMAIN_FUNCTIONS', '')) || \str_ends_with($host, System::getEnv('_APP_DOMAIN_SITES', ''))) { - throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'This domain is not connected to any Appwrite resource yet. Please configure custom domain or function domain to allow this request.'); + throw new AppwriteException(AppwriteException::RULE_NOT_FOUND, 'This domain is not connected to any Appwrite resources. Visit domains tab under function/site settings to configure it.'); } if (System::getEnv('_APP_OPTIONS_ROUTER_PROTECTION', 'disabled') === 'enabled') { diff --git a/app/views/general/error.phtml b/app/views/general/error.phtml index a3715e0156..f36f1957e7 100644 --- a/app/views/general/error.phtml +++ b/app/views/general/error.phtml @@ -7,16 +7,67 @@ $message = $this->getParam('message', ''); $trace = $this->getParam('trace', []); $projectName = $this->getParam('projectName', ''); $projectURL = $this->getParam('projectURL', ''); -$title = $this->getParam('title', '') +$title = $this->getParam('title', 'Error'); + +$knownTypes = ['build_not_ready', 'build_failed', 'rule_not_found']; +$label = ''; +$labelClass = ''; +$buttons = []; + +switch ($type) { + case 'build_not_ready': + $label = 'Deployment is still building'; + $message = 'The page will update after the build completes.'; + $labelClass = 'warning'; + $buttons = [ + [ + 'text' => 'Reload', + 'url' => '/', + 'class' => 'bordered-button' + ], + [ + 'text' => 'View logs', + 'url' => $projectURL, + 'class' => 'button' + ], + ]; + break; + case 'build_failed': + $label = 'Deployment build failed'; + $message = 'An error occurred during the build process.'; + $labelClass = 'error'; + $buttons = [ + [ + 'text' => 'View logs', + 'url' => '/', + 'class' => 'bordered-button' + ], + ]; + break; + case 'rule_not_found': + $label = 'Nothing is here yet'; + $message = 'This page is empty, but you can make it yours.'; + $buttons = [ + [ + 'text' => 'Start with this domain', + 'url' => '/', + 'class' => 'bordered-button' + ], + ]; + break; + default: + $label = 'Error ' . $code; + $message = $message; + break; +} ?> - - - + + getParam('title', '') as="font" type="font/woff2" crossorigin /> - - - - - - - - - - <?php echo $this->print($title); ?> -
-
-
-

Error print($code); ?>

-

print($message); ?>

-
-

Type

-

print($type); ?>

-
- -

Error Trace

- -
-
- - - $value) : ?> - - - - - - - -
print($key, self::FILTER_ESCAPE); ?> - - -
print(var_export($value, true), self::FILTER_ESCAPE); ?>
- -
print($value, self::FILTER_ESCAPE); ?>
- -
-
-
-
+
+
+
print($labelClass); ?>>print($label); ?>
+

print($message); ?>

+
+ + + + + + + print($type); ?> +
-
+
+ + +
+

Powered by

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
- \ No newline at end of file