Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
Better error handling via exit code
Browse files Browse the repository at this point in the history
- Change error handling from `eprintln!` to `bail!`
  • Loading branch information
zurawiki committed Mar 3, 2023
1 parent 11f48ac commit d35b2e7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/prompt.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::bail;
use async_openai::{
types::{
ChatCompletionRequestMessageArgs, CreateChatCompletionRequestArgs,
Expand Down Expand Up @@ -83,7 +84,7 @@ pub(crate) async fn chat_completion(
});
}
Err(e) => {
eprintln!("{e}");
bail!("{e}");
}
}
}
Expand Down Expand Up @@ -127,7 +128,7 @@ pub(crate) async fn completion(
Ok(ccr) => ccr.choices.iter().for_each(|c| {
print!("{}", c.text);
}),
Err(e) => eprintln!("{e}"),
Err(e) => bail!("{e}"),
}
}
println!();
Expand Down

0 comments on commit d35b2e7

Please sign in to comment.