Skip to main content

extract_human_error_message

Function extract_human_error_message 

Source
pub fn extract_human_error_message(body: &str) -> String
Expand description

Extract the most human-readable error message from a provider’s JSON error body.

Handles all known provider response schemas:

  • OpenAI/DeepSeek/ZAI/Anthropic: {"error": {"message": "..."}}
  • HuggingFace: {"error": "..."}
  • Gemini: {"error": {"status": "..."}}
  • FastAPI / OpenAI alternate: {"detail": "..."}
  • Generic: {"message": "..."}

Falls back to the raw body if no known field is found.