1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use maud::{html, Markup};

use dbui_core::Result;
use dbui_service::RequestContext;

pub fn not_found(ctx: &RequestContext, path: &str) -> Result<Markup> {
  let content = html! {
    div.uk-container {
      div.uk-section.uk-section-small {
        div.uk-container {
          div.uk-text-center {
            h1.uk-heading-hero {
              "404 Not Found"
            }
            div.uk-text-lead {
              (path)
            }
          }
        }
      }
    }
  };
  Ok(html! {
    (crate::simple(ctx, "Not Found", content)?)
  })
}

pub fn exception(ctx: &RequestContext, e: &dbui_core::Error) -> Result<Markup> {
  let content = html! {
    div.uk-container {
      div.uk-section.uk-section-small {
        div.uk-container {
          div.uk-text-center {
            h1.uk-heading-hero {
              (e.to_string())
            }
            div.uk-text-lead {
              @for e in e.iter().skip(1) {
                div { (e.to_string()) }
              }
            }
            div.uk-margin-top {
              div.uk-text-left {
                @if let Some(backtrace) = e.backtrace() {
                  (crate::components::backtrace::to_html(backtrace))
                }
              }
            }
          }
        }
      }
    }
  };
  Ok(html! {
    (crate::simple(ctx, "Error", content)?)
  })
}