mirror of
https://github.com/openai/codex.git
synced 2026-11-06 20:20:34 +00:00
- Move auth-owned source and tests into `auth` as a standalone workspace crate. - Move `create_client` into `codex-client` and import it directly where needed. Co-authored-by: Codex <noreply@openai.com>
17 lines
519 B
Rust
17 lines
519 B
Rust
use tracing::debug;
|
|
|
|
pub(crate) fn try_parse_error_message(text: &str) -> String {
|
|
debug!("Parsing server error response: {}", text);
|
|
let json = serde_json::from_str::<serde_json::Value>(text).unwrap_or_default();
|
|
if let Some(error) = json.get("error")
|
|
&& let Some(message) = error.get("message")
|
|
&& let Some(message_str) = message.as_str()
|
|
{
|
|
return message_str.to_string();
|
|
}
|
|
if text.is_empty() {
|
|
return "Unknown error".to_string();
|
|
}
|
|
text.to_string()
|
|
}
|