error message parsing problems
parent
498c963c20
commit
a725ab3928
|
|
@ -2,9 +2,9 @@ mod engine;
|
|||
|
||||
use crate::engine::params::Params;
|
||||
use crate::engine::response::DeeplResponse;
|
||||
use hyper::{body, Body, Client, Method, Request};
|
||||
use anyhow::{Context, Result};
|
||||
use hyper::{Body, Client, Method, Request, body};
|
||||
use hyper_tls::HttpsConnector;
|
||||
use anyhow::Result;
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() -> Result<()> {
|
||||
|
|
@ -22,7 +22,8 @@ async fn main() -> Result<()> {
|
|||
let res = client.request(request).await?;
|
||||
let body_bytes = body::to_bytes(res.into_body()).await?;
|
||||
let body = String::from_utf8(body_bytes.to_vec())?;
|
||||
let v: DeeplResponse = serde_json::from_str(&body)?;
|
||||
let v: DeeplResponse =
|
||||
serde_json::from_str(&body).context(format!("Could not parse body: {}", body))?;
|
||||
println!("{}", v.get_text(¶ms.target_lang));
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue