Files
codex/codex-rs/auth/util.rs
T
Ahmed IbrahimandCodex 60192f2a5f Make core auth a separate crate
- 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>
2026-03-19 12:55:20 -07:00

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()
}