diff --git a/crates/ezidam/src/error/mod.rs b/crates/ezidam/src/error/mod.rs index a4eb88a..26b5935 100644 --- a/crates/ezidam/src/error/mod.rs +++ b/crates/ezidam/src/error/mod.rs @@ -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() }, ), } diff --git a/crates/ezidam/src/error/status_code.rs b/crates/ezidam/src/error/status_code.rs index 1eac50d..232c3fc 100644 --- a/crates/ezidam/src/error/status_code.rs +++ b/crates/ezidam/src/error/status_code.rs @@ -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", - } - } } diff --git a/crates/ezidam/templates/base.html.tera b/crates/ezidam/templates/base.html.tera index f869950..b6804ef 100644 --- a/crates/ezidam/templates/base.html.tera +++ b/crates/ezidam/templates/base.html.tera @@ -1,14 +1,29 @@ - + + + + + + + {{ title }} + + + + + - - {% block content %}{% endblock content %}
ezidam version {{ version }}
- - \ No newline at end of file diff --git a/crates/ezidam/templates/error.html.tera b/crates/ezidam/templates/error.html.tera new file mode 100644 index 0000000..30fd70e --- /dev/null +++ b/crates/ezidam/templates/error.html.tera @@ -0,0 +1,29 @@ +{% extends "base" %} + +{% block content %} + + +
+
+
+
{{ http_code }}
+

{{ http_reason }}

+

+ {{ message }} +

+ +
+
+
+ + + + + +{% endblock content %} \ No newline at end of file diff --git a/crates/ezidam/templates/errors/404.html.tera b/crates/ezidam/templates/errors/404.html.tera deleted file mode 100644 index e7e675d..0000000 --- a/crates/ezidam/templates/errors/404.html.tera +++ /dev/null @@ -1,6 +0,0 @@ -{% extends "base" %} - -{% block content %} -
404 not found error!
-
{{ message }}
-{% endblock content %} \ No newline at end of file diff --git a/crates/ezidam/templates/errors/500.html.tera b/crates/ezidam/templates/errors/500.html.tera deleted file mode 100644 index 6b16ee1..0000000 --- a/crates/ezidam/templates/errors/500.html.tera +++ /dev/null @@ -1,6 +0,0 @@ -{% extends "base" %} - -{% block content %} -
500 internal error!
-
{{ message }}
-{% endblock content %} \ No newline at end of file diff --git a/crates/ezidam/templates/errors/unknown.html.tera b/crates/ezidam/templates/errors/unknown.html.tera deleted file mode 100644 index d4e3877..0000000 --- a/crates/ezidam/templates/errors/unknown.html.tera +++ /dev/null @@ -1,7 +0,0 @@ -{% extends "base" %} - -{% block content %} -
unknown error!
-
http code {{ http_code }}
-
{{ message }}
-{% endblock content %} \ No newline at end of file