feat: add configurable UCE error pages
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// Example page_compiler_error handler. Enable in /etc/uce/settings.cfg:
|
||||
// page_compiler_error=site/errors/compiler-error.uce
|
||||
// Served with status 500 when the requested unit fails to build. The full
|
||||
// compiler output stays available in context.call["error"], so this page can
|
||||
// show as much or as little of it as the deployment wants.
|
||||
|
||||
RENDER(Request& context)
|
||||
{
|
||||
DTree error = context.call["error"];
|
||||
|
||||
<>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Build failed</title>
|
||||
<style>
|
||||
body { font-family: system-ui, sans-serif; background: #1c1017; color: #fde8e8; margin: 0; min-height: 100vh; }
|
||||
main { max-width: 60rem; margin: 0 auto; padding: 3rem 2rem; }
|
||||
h1 { color: #f87171; }
|
||||
code { color: #fca5a5; }
|
||||
pre { background: #0f0a0d; color: #e2e8f0; padding: 1rem; border-radius: 0.5rem; overflow-x: auto; font-size: 0.85rem; line-height: 1.5; }
|
||||
.meta { color: #9f8a93; font-size: 0.9rem; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>This page failed to build</h1>
|
||||
<p>Source: <code><?= error["source"].to_string() ?></code></p>
|
||||
<p class="meta">Generated C++: <code><?= error["generated_cpp"].to_string() ?></code></p>
|
||||
<pre><?= error["compiler_output"].to_string() ?></pre>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</>
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Example page_compiling handler. Enable in /etc/uce/settings.cfg:
|
||||
// page_compiling=site/errors/compiling.uce
|
||||
// Served with status 503 while the requested unit is being (re)built; the
|
||||
// page refreshes itself until the build finishes and the real page renders.
|
||||
|
||||
RENDER(Request& context)
|
||||
{
|
||||
context.header["Refresh"] = "2";
|
||||
String source = context.call["error"]["source"].to_string();
|
||||
|
||||
<>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="refresh" content="2">
|
||||
<title>Building page…</title>
|
||||
<style>
|
||||
body { font-family: system-ui, sans-serif; background: #0f172a; color: #e2e8f0; margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
|
||||
main { text-align: center; max-width: 40rem; padding: 2rem; }
|
||||
.pulse { width: 3rem; height: 3rem; margin: 0 auto 1.5rem; border-radius: 50%; background: #38bdf8; animation: pulse 1.2s ease-in-out infinite; }
|
||||
@keyframes pulse { 0%, 100% { transform: scale(0.8); opacity: 0.5; } 50% { transform: scale(1); opacity: 1; } }
|
||||
code { color: #94a3b8; font-size: 0.85rem; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="pulse"></div>
|
||||
<h1>Building this page…</h1>
|
||||
<p>The page is being compiled and will load automatically in a moment.</p>
|
||||
<p><code><?= source ?></code></p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</>
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Example page_runtime_error handler. Enable in /etc/uce/settings.cfg:
|
||||
// page_runtime_error=site/errors/runtime-error.uce
|
||||
// Served with status 500 after a recovered fault or uncaught exception. Keep
|
||||
// runtime error pages simple: they run in a worker that may have just
|
||||
// recovered from a fatal signal, so avoid database work or heavy components.
|
||||
|
||||
RENDER(Request& context)
|
||||
{
|
||||
DTree error = context.call["error"];
|
||||
String signal_name = error["signal_name"].to_string();
|
||||
|
||||
<>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Something went wrong</title>
|
||||
<style>
|
||||
body { font-family: system-ui, sans-serif; background: #1c1017; color: #fde8e8; margin: 0; min-height: 100vh; }
|
||||
main { max-width: 60rem; margin: 0 auto; padding: 3rem 2rem; }
|
||||
h1 { color: #f87171; }
|
||||
code { color: #fca5a5; }
|
||||
pre { background: #0f0a0d; color: #e2e8f0; padding: 1rem; border-radius: 0.5rem; overflow-x: auto; font-size: 0.85rem; line-height: 1.5; }
|
||||
.meta { color: #9f8a93; font-size: 0.9rem; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>Something went wrong</h1>
|
||||
<p><?= error["title"].to_string() ?></p>
|
||||
<p class="meta">Request: <code><?= error["request_uri"].to_string() ?></code></p>
|
||||
<? if(error["details"].to_string() != "") { ?>
|
||||
<p class="meta">Details: <?= error["details"].to_string() ?></p>
|
||||
<? } ?>
|
||||
<? if(signal_name != "") { ?>
|
||||
<p class="meta">Signal: <?= signal_name ?></p>
|
||||
<? } ?>
|
||||
<? if(error["trace"].to_string() != "") { ?>
|
||||
<pre><?= error["trace"].to_string() ?></pre>
|
||||
<? } ?>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</>
|
||||
}
|
||||
Reference in New Issue
Block a user