More accurate panic message on mutex poison
This commit is contained in:
parent
915dd13e74
commit
e7d09fb314
3 changed files with 8 additions and 3 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1438,7 +1438,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "simple-analytics"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-std",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "simple-analytics"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
|
|
@ -13,7 +13,12 @@ pub async fn submit_event(mut req: Request<State>) -> tide::Result {
|
|||
|
||||
{
|
||||
let state = req.state().clone();
|
||||
let connection = state.0.lock().expect("failed to get read lock");
|
||||
let connection = if let Ok(v) = state.0.lock() {
|
||||
v
|
||||
} else {
|
||||
error!("database mutex is poisoned. Restarting is probably required!");
|
||||
panic!("database mutex is poisoned");
|
||||
};
|
||||
|
||||
if let Err(err) = connection.execute(
|
||||
"INSERT INTO analytics (id, event_name, data) VALUES (?1, ?2, ?3)",
|
||||
|
|
Loading…
Reference in a new issue