From a72221f016fcb8a99548b3b57c9b279f01874948 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 28 Jun 2020 23:03:41 -0400 Subject: [PATCH] Avoid panics in the webserver - Don't panic if looking at two local builds in the dashboard - Don't panic if there are no pstat results available --- database/src/pool/sqlite.rs | 1 - site/src/server.rs | 10 +++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/database/src/pool/sqlite.rs b/database/src/pool/sqlite.rs index a71b09d71..edffb8686 100644 --- a/database/src/pool/sqlite.rs +++ b/database/src/pool/sqlite.rs @@ -331,7 +331,6 @@ impl Connection for SqliteConnection { cid.and_then(|cid| { query .query_row(params![&sid, &cid.0], |row| row.get(0)) - .optional() .unwrap_or_else(|e| { panic!("{:?}: series={:?}, aid={:?}", e, sid, cid); }) diff --git a/site/src/server.rs b/site/src/server.rs index 721f3e052..b562a2946 100644 --- a/site/src/server.rs +++ b/site/src/server.rs @@ -109,14 +109,18 @@ pub async fn handle_dashboard(data: Arc) -> ServerResult a.cmp(&b), (_, _) => { + use std::cmp::Ordering; + if a.starts_with("beta") && b.starts_with("beta") { a.cmp(b) } else if a.starts_with("beta") { - std::cmp::Ordering::Greater + Ordering::Greater } else if b.starts_with("beta") { - std::cmp::Ordering::Less + Ordering::Less } else { - panic!("unexpected version") + // These are both local ids, not a commit. + // There's no way to tell which version they are, so just pretend they're the same. + Ordering::Equal } } }