Skip to content

Commit

Permalink
fix: Don't crash on incomplete expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
leoshimo committed Nov 14, 2024
1 parent 243edc5 commit 48f1c32
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions vrsjmp/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,19 @@ impl Client {
fn set_query(query: &str, state: tauri::State<State>) -> Vec<serde_json::Value> {
let mut matcher = state.matcher.lock().unwrap();

// TODO: Contents of `query` should be escaped
let request = match Form::from_expr(&format!("(begin (bind_srv :vrsjmp) (get_items \"{}\"))", query)) {
Ok(f) => f,
Err(lyric::Error::IncompleteExpression(_)) => return vec![],
Err(e) => {
error!("Invalid form for user query - {e}");
return vec![];
}
};

let response = state
.client
.request(
Form::from_expr(&format!(
"(begin (bind_srv :vrsjmp) (get_items \"{}\"))",
query
))
.unwrap(),
)
.request(request)
.unwrap();

let items = match response.contents.unwrap() {
Expand Down

0 comments on commit 48f1c32

Please sign in to comment.