Improve error handling.

This commit is contained in:
Justus Winter 2019-03-05 12:47:19 +01:00
parent 9ac8dac95b
commit 204233b663
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386
2 changed files with 6 additions and 14 deletions

2
dist/templates/generic-error.html.hbs vendored Normal file
View File

@ -0,0 +1,2 @@
{{#> layout }}
{{/layout}}

View File

@ -442,7 +442,7 @@ fn by_keyid(db: rocket::State<Polymorphic>, domain: rocket::State<Domain>,
#[get("/vks/v1/verify/<token>")]
fn verify(
db: rocket::State<Polymorphic>, domain: rocket::State<Domain>, token: String,
) -> result::Result<Template, Custom<String>> {
) -> MyResponse {
match db.verify_token(&token) {
Ok(Some((userid, fpr))) => {
let context = templates::Verify {
@ -454,20 +454,10 @@ fn verify(
commit: env!("VERGEN_SHA_SHORT").to_string(),
};
Ok(Template::render("verify", context))
}
Ok(None) | Err(_) => {
let context = templates::Verify {
verified: false,
domain: domain.0.clone(),
userid: "".into(),
fpr: "".into(),
version: env!("VERGEN_SEMVER").to_string(),
commit: env!("VERGEN_SHA_SHORT").to_string(),
};
Ok(Template::render("verify", context))
MyResponse::ok("verify", context)
}
Ok(None) => MyResponse::not_found(Some("generic-error"), None),
Err(e) => MyResponse::ise(e),
}
}