Skip to main content
The SDK raises three error types. Two come from a client call, and one comes from webhook verification. Everything else is an Error with a stable message from a local check that runs before any request. GolApiError and GolTransportError are exported from both entry points. GolWebhookVerificationError is exported from @gol/sdk/server only, because verification itself is server-only.

GolApiError

Branch on code, not on status or message. The code set is stable across versions; a status can change with the shape of a request and a message is written for people. Understand API errors lists every code and what to check. correlationId is also returned in the x-correlation-id response header, and the client prefers the one in the body. Log it with the operation you attempted, never with the API key or the full Authorization header.

GolTransportError

GolTransportError means the SDK never got a usable answer. It has no code and no status, because there is no response to attribute it to. The original failure is on cause when there was one.
It is also thrown before any request in these cases:
  • baseUrl is not an absolute URL, uses plain HTTP on a non-local host, or carries credentials, a query string, or a fragment.
  • The API key does not match gol_test_... or gol_live_....
  • A GolManagementClient method that needs a session was called with no sessionToken.
  • prepareGasExecution or submitGasExecution received an actionId that is not 32 bytes of hex.
  • The API answered 204 for a route that returns a body, or answered with something that is not JSON.
  • A polling helper passed its timeoutMs.
Each of those is a bug or a misconfiguration, not a transient condition, so a retry loop will not fix it.

Retrying a value-moving request

A transport failure is ambiguous: your request may have been fully processed while the answer was lost. That is only safe because the action ID is the idempotency key.
Never mint a new action ID to escape an ambiguous failure, and never assume a failed value-moving call did not happen. Reusing the same ID and signature returns the original execution without moving value again; changing the ID turns a retry into a second transfer.

Local checks throw plain Error

The owner helpers and encoders validate their input before any network call or wallet prompt. These are plain Error objects whose message is a stable identifier, not a class, so match on the message. A throw means the SDK or the API would not proceed. None of them means the owner’s account is unsafe, and none should be resolved by retrying with altered inputs. Owner signing covers the ones you will meet most.

Webhook verification failures

verifyWebhook throws GolWebhookVerificationError for exactly four reasons, and all four should be answered with a non-2xx status so GOL retries.
Signature comparison is timing-safe, and the check runs before the body is parsed, so a forged delivery cannot reach your handler.

Log without leaking

Keep the operation, the project ID, the action or policy ID, the status, the code, and the correlation ID. Leave out the API key, the developer session token, the webhook secret, and the full Authorization header. A correlation ID with no credential beside it is enough for GOL to find the request.