mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-11 22:10:09 +01:00
chore: print status messages on failed request
This commit is contained in:
parent
32e2cb71e8
commit
7d41d2ba43
1 changed files with 13 additions and 2 deletions
|
|
@ -127,11 +127,22 @@ pub async fn ai_suggestion(last_command: &str, error_msg: &str) {
|
||||||
.header("Content-Type", "application/json")
|
.header("Content-Type", "application/json")
|
||||||
.bearer_auth(&conf.key)
|
.bearer_auth(&conf.key)
|
||||||
.send()
|
.send()
|
||||||
.await;
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let mut stream = res.unwrap().bytes_stream();
|
if res.status() != 200 {
|
||||||
|
eprintln!("AI module: Status code: {}", res.status());
|
||||||
|
eprintln!(
|
||||||
|
"AI module: Error message:\n {}",
|
||||||
|
res.text().await.unwrap().replace("\n", "\n ")
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut stream = res.bytes_stream();
|
||||||
let mut json_buffer = String::new();
|
let mut json_buffer = String::new();
|
||||||
let mut buffer = buffer::Buffer::new();
|
let mut buffer = buffer::Buffer::new();
|
||||||
|
|
||||||
while let Some(item) = stream.next().await {
|
while let Some(item) = stream.next().await {
|
||||||
let item = item.unwrap();
|
let item = item.unwrap();
|
||||||
let str = std::str::from_utf8(&item).unwrap();
|
let str = std::str::from_utf8(&item).unwrap();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue