error templates: use tabler, and use same template for all errors
This commit is contained in:
parent
05b1a597ea
commit
65bfd02fbf
7 changed files with 52 additions and 33 deletions
|
|
@ -16,11 +16,13 @@ impl Error {
|
|||
Self {
|
||||
status,
|
||||
template: Template::render(
|
||||
status.template_name(),
|
||||
"error",
|
||||
context! {
|
||||
title: format!("{} Error", status.http_code().code),
|
||||
message: message.to_string(),
|
||||
version: env!("CARGO_PKG_VERSION"),
|
||||
http_code: status.http_code().code,
|
||||
http_reason: status.http_code().reason_lossy()
|
||||
},
|
||||
),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,4 @@ impl StatusCode {
|
|||
StatusCode::Unknown(status) => status,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn template_name(self) -> &'static str {
|
||||
match self {
|
||||
StatusCode::NotFound => "errors/404",
|
||||
StatusCode::InternalServerError => "errors/500",
|
||||
StatusCode::Unknown(_) => "errors/unknown",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,29 @@
|
|||
<html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
|
||||
<title>{{ title }}</title>
|
||||
<!-- CSS files -->
|
||||
<link href="/css/tabler.min.css" rel="stylesheet"/>
|
||||
<link href="/css/demo.min.css" rel="stylesheet"/>
|
||||
<style>
|
||||
@import url('https://rsms.me/inter/inter.css');
|
||||
:root {
|
||||
--tblr-font-sans-serif: 'Inter Var', -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
|
||||
}
|
||||
body {
|
||||
font-feature-settings: "cv03", "cv04", "cv11";
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
{% block content %}{% endblock content %}
|
||||
|
||||
<div>
|
||||
<div>ezidam version {{ version }}</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
||||
29
crates/ezidam/templates/error.html.tera
Normal file
29
crates/ezidam/templates/error.html.tera
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{% extends "base" %}
|
||||
|
||||
{% block content %}
|
||||
<body class=" border-top-wide border-primary d-flex flex-column">
|
||||
<script src="/js/demo-theme.min.js?1677614948"></script>
|
||||
<div class="page page-center">
|
||||
<div class="container-tight py-4">
|
||||
<div class="empty">
|
||||
<div class="empty-header">{{ http_code }}</div>
|
||||
<p class="empty-title">{{ http_reason }}</p>
|
||||
<p class="empty-subtitle text-muted">
|
||||
{{ message }}
|
||||
</p>
|
||||
<div class="empty-action">
|
||||
<a href="/" class="btn btn-primary">
|
||||
<!-- Download SVG icon from http://tabler-icons.io/i/arrow-left -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l14 0" /><path d="M5 12l6 6" /><path d="M5 12l6 -6" /></svg>
|
||||
Take me home
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Libs JS -->
|
||||
<!-- Tabler Core -->
|
||||
<script src="/js/tabler.min.js" defer></script>
|
||||
<script src="/js/demo.min.js" defer></script>
|
||||
</body>
|
||||
{% endblock content %}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
{% extends "base" %}
|
||||
|
||||
{% block content %}
|
||||
<div>404 not found error!</div>
|
||||
<div>{{ message }}</div>
|
||||
{% endblock content %}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
{% extends "base" %}
|
||||
|
||||
{% block content %}
|
||||
<div>500 internal error!</div>
|
||||
<div>{{ message }}</div>
|
||||
{% endblock content %}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
{% extends "base" %}
|
||||
|
||||
{% block content %}
|
||||
<div>unknown error!</div>
|
||||
<div>http code {{ http_code }}</div>
|
||||
<div>{{ message }}</div>
|
||||
{% endblock content %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue