Skip to content

Commit

Permalink
properly handle response
Browse files Browse the repository at this point in the history
  • Loading branch information
carueda committed Feb 6, 2024
1 parent 84bcb44 commit 4225c76
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "odss2dash"
version = "2.1.2"
version = "2.2.0"
authors = [
"Carlos A. Rueda <[email protected]>",
]
Expand Down
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
2024-02

2.2.0

- trackdb_client: properly handle response, e.g., when an invalid platform ID is queried.

2.1.2

- some lib updates
Expand Down
26 changes: 20 additions & 6 deletions src/trackdb_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ pub fn get_platforms() -> Vec<PlatformRes> {
match request.send() {
Ok(res) => {
if res.is_success() {
let platforms_res = res.json::<Vec<PlatformRes>>().unwrap();
log::debug!("odss platforms_res = {:?}", platforms_res);
platforms_res
match res.json::<Vec<PlatformRes>>() {
Ok(platforms_res) => {
log::debug!("odss platforms_res = {:?}", platforms_res);
platforms_res
}
Err(e) => {
log::error!("could not parse response: {}", e);
vec![]
}
}
} else {
log::error!(
"GET {endpoint}: response: status={}, body={}",
Expand All @@ -79,9 +86,16 @@ pub fn get_platform(platform_id: &str) -> Option<PlatformRes> {
match request.send() {
Ok(res) => {
if res.is_success() {
let platforms_res = res.json::<PlatformRes>().unwrap();
log::debug!("odss platform_res = {:?}", platforms_res);
Some(platforms_res)
match res.json::<PlatformRes>() {
Ok(platform_res) => {
log::debug!("odss platform_res = {:?}", platform_res);
Some(platform_res)
}
Err(e) => {
log::error!("could not parse response: {}", e);
None
}
}
} else {
log::error!(
"GET {endpoint} response: status={}, body={}",
Expand Down

0 comments on commit 4225c76

Please sign in to comment.