summaryrefslogtreecommitdiffstats
path: root/src/client/common.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-04-25 14:39:31 +0800
committerGitHub <noreply@github.com>2024-04-25 14:39:31 +0800
commit1a56e38fe22336e6b6587ff7d99218295e28235f (patch)
tree0b19a492fe27ad2f5f8a98f1eca89cb73d3fcd50 /src/client/common.rs
parenta193710a7f88de12ef11c5a5c66a5591150fe247 (diff)
downloadaichat-1a56e38fe22336e6b6587ff7d99218295e28235f.tar.gz
refactor: fix typo and some error message (#438)
Diffstat (limited to 'src/client/common.rs')
-rw-r--r--src/client/common.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/client/common.rs b/src/client/common.rs
index 1b74de8..5a2fd55 100644
--- a/src/client/common.rs
+++ b/src/client/common.rs
@@ -108,7 +108,7 @@ macro_rules! register_client {
return create_config(&$client::PROMPTS, $client::NAME)
}
)+
- anyhow::bail!("Unknown client {}", client)
+ anyhow::bail!("Unknown client '{}'", client)
}
pub fn list_models(config: &$crate::config::Config) -> Vec<$crate::client::Model> {
@@ -192,7 +192,9 @@ macro_rules! config_get_fn {
format!("{}_{}", env_prefix, stringify!($field_name)).to_ascii_uppercase();
std::env::var(&env_name).ok()
})
- .ok_or_else(|| anyhow::anyhow!("Miss {}", stringify!($field_name)))
+ .ok_or_else(|| {
+ anyhow::anyhow!("Miss '{}' in client configuration", stringify!($field_name))
+ })
}
};
}
@@ -435,7 +437,7 @@ pub fn catch_error(data: &Value, status: u16) -> Result<()> {
} else if let Some(message) = data["message"].as_str() {
bail!("{message}");
}
- bail!("Invalid response, status: {status}, data: {data}");
+ bail!("Invalid response data: {data} (status: {status})");
}
pub fn maybe_catch_error(data: &Value) -> Result<()> {