Skip to content

Commit

Permalink
sorcery-ai suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
aaravm committed Jul 1, 2024
1 parent ebc9bec commit e56a623
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
16 changes: 13 additions & 3 deletions lib/src/tes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ impl Task {
let task: TesTask = from_str(&resp_str)?;
Ok(task.state.unwrap())
}
Err(e) => Err(e),
Err(e) => {
let err_msg = format!("HTTP request failed: {}", e);
eprintln!("{}", err_msg);
Err(Box::new(std::io::Error::new(std::io::ErrorKind::Other, err_msg)))
}
}
}

Expand Down Expand Up @@ -218,7 +222,13 @@ impl TES {
let task: TesListTasksResponse = from_str(&resp_str)?;
Ok(task)
}
Err(e) => Err(e),
Err(e) => {
eprintln!("HTTP request failed: {:?}", e);
Err(Box::new(std::io::Error::new(
std::io::ErrorKind::Other,
format!("HTTP request failed: {:?}", e),
)))
}
}
}
}
Expand Down Expand Up @@ -258,7 +268,7 @@ mod tests {
async fn test_task_create() {
setup();
let (task, _tes) = create_task().await.expect("Failed to create task");
assert!(!task.id.is_empty(), "Task ID should not be empty"); // doube check if it's a correct assertion
assert!(!task.id.is_empty(), "Task ID should not be empty"); // double check if it's a correct assertion
}

#[tokio::test]
Expand Down
8 changes: 7 additions & 1 deletion lib/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ impl Transport {
);

if let Some(ref params_value) = params {
request_builder = request_builder.query(params_value);
// Validate or log params_value before setting it as query parameters
if params_value.is_object() {
request_builder = request_builder.query(params_value);
} else {
error!("params_value is not an object and cannot be used as query parameters: {:?}", params_value);
return Err(Box::new(std::io::Error::new(std::io::ErrorKind::InvalidInput, "params_value must be an object")));
}
}

if let Some(ref data) = data {
Expand Down

0 comments on commit e56a623

Please sign in to comment.