16 lines
451 B
Rust
Raw Normal View History

2019-08-17 00:58:17 +03:00
use crate::errors::{err_msg, AppResult};
use crate::sqlite;
2019-08-18 18:21:12 +02:00
pub fn query(query: &str) -> AppResult<String> {
let response = sqlite::call(query.as_bytes());
2019-08-17 00:58:17 +03:00
2019-08-18 18:24:10 +02:00
// Add more details to error message
2019-08-18 18:19:35 +02:00
String::from_utf8(response).map_err(|e| {
log::error!("unable to decode result from bytes: {:#x?}", bytes);
err_msg(&format!(
"unable to decode result from bytes {:#x?}: {}",
2019-08-18 18:21:12 +02:00
query, e
2019-08-18 18:19:35 +02:00
))
})
2019-08-17 00:58:17 +03:00
}