extract_cf_error

Function extract_cf_error 

Source
pub fn extract_cf_error(body: &Value) -> String
Expand description

Extract a human-readable error message from a Cloudflare API response body.

Checks errors[0].message first, falls back to the raw body.

ยงExample

use serde_json::json;
use stygian_graph::adapters::cloudflare_crawl::extract_cf_error;

let body = json!({ "errors": [{ "code": 1000, "message": "Invalid token" }] });
assert_eq!(extract_cf_error(&body), "1000: Invalid token");