mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-06 08:10:48 +00:00
Split the 66-line generic_cloud_api function into focused helpers to reduce complexity and eliminate duplication: - _parse_api_response: Extracts HTTP code and response body (10 lines) - _make_api_request: Builds curl args and executes request (27 lines) - _handle_api_transient_error: Centralizes retry logic for all error types (24 lines) Main function reduced from 66 to 41 lines (38% reduction). Behavior unchanged: still retries on network errors and transient HTTP codes (429, 503), with exponential backoff. All test assertions pass. This extraction pattern makes it clearer how retry logic flows and easier to modify error handling in the future without duplicating patterns. Co-authored-by: A <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| common.sh | ||