Skip to content

Commit

Permalink
Avoid panics in the webserver
Browse files Browse the repository at this point in the history
- Don't panic if looking at two local builds in the dashboard
- Don't panic if there are no pstat results available
  • Loading branch information
jyn514 committed Jun 30, 2020
1 parent d6e24e9 commit a72221f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion database/src/pool/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
Expand Down
10 changes: 7 additions & 3 deletions site/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,18 @@ pub async fn handle_dashboard(data: Arc<InputData>) -> ServerResult<dashboard::R
) {
(Some(a), Some(b)) => 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
}
}
}
Expand Down

0 comments on commit a72221f

Please sign in to comment.