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]]
|
[[package]]
|
||||||
name = "simple-analytics"
|
name = "simple-analytics"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-std",
|
"async-std",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "simple-analytics"
|
name = "simple-analytics"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
@ -13,7 +13,12 @@ pub async fn submit_event(mut req: Request<State>) -> tide::Result {
|
||||||
|
|
||||||
{
|
{
|
||||||
let state = req.state().clone();
|
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(
|
if let Err(err) = connection.execute(
|
||||||
"INSERT INTO analytics (id, event_name, data) VALUES (?1, ?2, ?3)",
|
"INSERT INTO analytics (id, event_name, data) VALUES (?1, ?2, ?3)",
|
||||||
|
|
Loading…
Reference in a new issue