Skip to content

Commit

Permalink
log: add json bytes to transaction list pluggy client api error log
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasauler committed Dec 17, 2024
1 parent 107a752 commit ccec64e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/client/pluggy/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,25 @@ pub async fn list_transactions(
.send()
.await?;

let transactions: ListTransactionsResponse = match resp.status() {
StatusCode::OK => resp.json().await?,
match resp.status() {
StatusCode::OK => (),
StatusCode::BAD_REQUEST => return Ok(ListTransactionsOutcome::Missing),
StatusCode::INTERNAL_SERVER_ERROR => return Ok(ListTransactionsOutcome::Internal),
_ => {
let res = resp.text().await?;
tracing::error!(?res, "received unexpected error from list transactions");
bail!("unknown error: {}", res)
bail!("received unexpected status code from list transactions")
}
};

let bytes = resp.bytes().await?;
let transactions: ListTransactionsResponse = serde_json::from_slice(&bytes).map_err(|e| {
tracing::error!(
?e,
?bytes,
"error deserializing transactions list from pluggy"
);
e
})?;

Ok(ListTransactionsOutcome::Success(transactions))
}

Expand Down

0 comments on commit ccec64e

Please sign in to comment.