Skip to content
Docs

Errors

Error object shape

Every error has a stable code, a message, and a retryable flag, over HTTP and in the SDKs.

Overview

The Gray3 Cloud API, the Gray3 Ledger API, and the SDKs share one error model. Over HTTP the error is returned inside { "error": … }. The TypeScript packages throw a GrayError with the same code.

json
{
  "error": {
    "code": "unsupported_capability",
    "message": "Prices are not available on testnets.",
    "retryable": false
  }
}
FieldRequiredDescription
codeYesStable machine code. Use it in application logic.
messageYesHuman-readable text. It may be replaced with a generic message, so do not parse it.
retryableYesWhether the same request can be retried safely with backoff

SDK properties

javascript
import { Gray, isGrayError } from "@gray3/cloud";

try {
  await gray.portfolio.get({ chainId: "ethereum", address });
} catch (err) {
  if (isGrayError(err)) {
    console.log(err.code, err.httpStatus, err.retryable, err.message);
  }
}
FieldRequiredDescription
err.codeYesstring
err.messageYesstring
err.retryableYesboolean
err.httpStatusYesnumber
err.causeNoOptional underlying error, for logging only

Message sanitization

When an underlying data service returns a message that is not suitable for end users, the Gray3 Cloud API replaces it with a generic message for that code (for example "Portfolio data is temporarily unavailable. Please retry."). Safe app-authored messages pass through unchanged.

Multi responses vs thrown errors

For portfolio multi and DeFi multi, a failure on one chain usually appears inside data.chains[i].error (string) without failing the whole HTTP call. A thrown GrayError means the request itself failed (auth, empty address, batch limit, total outage). Prices multi returns failures[] alongside quotes[].