fix(digitalocean): catch billing 403 thrown by doApi on droplet creation (#2628)

doApi() throws on any non-2xx response before the isBillingError() check
at the call site could execute, making billing error detection dead code.

Wrap the POST /droplets call in asyncTryCatch so the thrown error message
(which includes the response body) is checked with isBillingError(). If it
matches a billing pattern, handleBillingError() is shown with the billing
page link and retry prompt — same UX as the proactive first-run warning.

Also adds a test asserting isBillingError() matches errors in the format
doApi throws (regression guard for #2395).

Fixes #2395

Agent: issue-fixer

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
A 2026-03-14 15:09:48 -07:00 committed by GitHub
parent d435963dbc
commit 0f9bbd399c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 8 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@openrouter/spawn",
"version": "0.18.2",
"version": "0.18.3",
"type": "module",
"bin": {
"spawn": "cli.js"