mirror of
https://github.com/fluencelabs/fluid
synced 2025-04-24 22:32:16 +00:00
Merge pull request #2 from fluencelabs/optimize_query
This commit is contained in:
commit
cf23178ec7
@ -4,21 +4,12 @@ use crate::sqlite;
|
|||||||
pub fn query(query: &str) -> AppResult<String> {
|
pub fn query(query: &str) -> AppResult<String> {
|
||||||
let response = sqlite::call(query.as_bytes());
|
let response = sqlite::call(query.as_bytes());
|
||||||
|
|
||||||
// Decode query result to a utf8 string
|
// Add more details to error message
|
||||||
let result_str = std::str::from_utf8(&response);
|
String::from_utf8(response).map_err(|e| {
|
||||||
|
log::error!("unable to decode result from bytes: {:#x?}", bytes);
|
||||||
// Log if there's an error
|
|
||||||
if result_str.is_err() {
|
|
||||||
log::error!("unable to decode result from bytes: {:#x?}", response);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wrap error with a better message, and return Result
|
|
||||||
result_str
|
|
||||||
.map_err(|e| {
|
|
||||||
err_msg(&format!(
|
err_msg(&format!(
|
||||||
"unable to decode result from bytes {:#x?}: {}",
|
"unable to decode result from bytes {:#x?}: {}",
|
||||||
response, e
|
query, e
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
.map(|s| s.to_string())
|
|
||||||
}
|
}
|
||||||
|
@ -4,21 +4,12 @@ use crate::sqlite;
|
|||||||
pub fn query(query: &str) -> AppResult<String> {
|
pub fn query(query: &str) -> AppResult<String> {
|
||||||
let response = sqlite::call(query.as_bytes());
|
let response = sqlite::call(query.as_bytes());
|
||||||
|
|
||||||
// Decode query result to a utf8 string
|
// Add more details to error message
|
||||||
let result_str = std::str::from_utf8(&response);
|
String::from_utf8(response).map_err(|e| {
|
||||||
|
log::error!("unable to decode result from bytes: {:#x?}", bytes);
|
||||||
// Log if there's an error
|
|
||||||
if result_str.is_err() {
|
|
||||||
log::error!("unable to decode result from bytes: {:#x?}", response);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wrap error with a better message, and return Result
|
|
||||||
result_str
|
|
||||||
.map_err(|e| {
|
|
||||||
err_msg(&format!(
|
err_msg(&format!(
|
||||||
"unable to decode result from bytes {:#x?}: {}",
|
"unable to decode result from bytes {:#x?}: {}",
|
||||||
response, e
|
query, e
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
.map(|s| s.to_string())
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user