⚡ Adds error handling for hit inserting
This commit is contained in:
@@ -63,8 +63,7 @@ pub async fn get(id: &str, meta: ReqMeta, state: &State<AppState>) -> Result<Nam
|
|||||||
return Err(Status::NotFound);
|
return Err(Status::NotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: handle possible error
|
let result = diesel::insert_into(hits::table)
|
||||||
let _ = diesel::insert_into(hits::table)
|
|
||||||
.values(&Hit {
|
.values(&Hit {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
tracker_id: id,
|
tracker_id: id,
|
||||||
@@ -74,6 +73,9 @@ pub async fn get(id: &str, meta: ReqMeta, state: &State<AppState>) -> Result<Nam
|
|||||||
created_at: Utc::now().naive_utc(),
|
created_at: Utc::now().naive_utc(),
|
||||||
})
|
})
|
||||||
.execute(&mut *db);
|
.execute(&mut *db);
|
||||||
|
if result.is_err() {
|
||||||
|
error!("Failed to insert hit: {:?}", result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NamedFile::open(Path::new(state.image_path.as_str()))
|
NamedFile::open(Path::new(state.image_path.as_str()))
|
||||||
|
|||||||
Reference in New Issue
Block a user