Skip to content

Commit

Permalink
refactor: catch api error (#861)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden authored Sep 12, 2024
1 parent 8b3bd63 commit 99005a2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/client/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@ pub fn catch_error(data: &Value, status: u16) -> Result<()> {
json_str_from_map(error, "message"),
) {
bail!("{message} (type: {typ})");
} else if let (Some(typ), Some(message)) = (
json_str_from_map(error, "code"),
json_str_from_map(error, "message"),
) {
bail!("{message} (code: {typ})");
}
} else if let Some(error) = data["errors"][0].as_object() {
if let (Some(code), Some(message)) = (
Expand Down

0 comments on commit 99005a2

Please sign in to comment.