Skip to content

Commit 2c5171f

Browse files
committed
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
1 parent ef7734e commit 2c5171f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

database/src/pool/sqlite.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ impl Connection for SqliteConnection {
331331
cid.and_then(|cid| {
332332
query
333333
.query_row(params![&sid, &cid.0], |row| row.get(0))
334-
.optional()
335334
.unwrap_or_else(|e| {
336335
panic!("{:?}: series={:?}, aid={:?}", e, sid, cid);
337336
})

site/src/server.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,18 @@ pub async fn handle_dashboard(data: Arc<InputData>) -> ServerResult<dashboard::R
109109
) {
110110
(Some(a), Some(b)) => a.cmp(&b),
111111
(_, _) => {
112+
use std::cmp::Ordering;
113+
112114
if a.starts_with("beta") && b.starts_with("beta") {
113115
a.cmp(b)
114116
} else if a.starts_with("beta") {
115-
std::cmp::Ordering::Greater
117+
Ordering::Greater
116118
} else if b.starts_with("beta") {
117-
std::cmp::Ordering::Less
119+
Ordering::Less
118120
} else {
119-
panic!("unexpected version")
121+
// These are both local ids, not a commit.
122+
// There's no way to tell which version they are, so just pretend they're the same.
123+
Ordering::Equal
120124
}
121125
}
122126
}

0 commit comments

Comments
 (0)