feat(error-handling): add network error differentiation, retry, and REST API detection (C.5)
WordPress client improvements: - Add ConnectionError exception for network-level failures - Differentiate DNS, SSL, timeout, and connection refused errors - Add retry with exponential backoff for transient errors (502, 503, 504, 429) - Auth/config errors are never retried - Add request timeout (30s default) Health check improvements: - Detect REST API disabled (403/404 on /wp-json) - Classify errors by type: dns_failure, ssl_error, timeout, connection_refused Bare except cleanup: - Replaced all bare except: with except Exception: across 12 files Tests: 303 passed (13 new tests for error handling) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -190,7 +190,7 @@ class MenusHandler:
|
||||
# Try custom endpoint first, fallback to standard if not available
|
||||
try:
|
||||
menus = await self.client.get("menus", use_custom_namespace=True)
|
||||
except:
|
||||
except Exception:
|
||||
# Fallback: use wp/v2/navigation endpoint (WP 5.9+)
|
||||
menus = await self.client.get("navigation")
|
||||
|
||||
@@ -216,7 +216,7 @@ class MenusHandler:
|
||||
# Get menu details
|
||||
try:
|
||||
menu = await self.client.get(f"menus/{menu_id}", use_custom_namespace=True)
|
||||
except:
|
||||
except Exception:
|
||||
menu = await self.client.get(f"navigation/{menu_id}")
|
||||
|
||||
# Get menu items
|
||||
@@ -256,7 +256,7 @@ class MenusHandler:
|
||||
|
||||
try:
|
||||
menu = await self.client.post("menus", json_data=data, use_custom_namespace=True)
|
||||
except:
|
||||
except Exception:
|
||||
# Try navigation endpoint
|
||||
menu = await self.client.post("navigation", json_data=data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user