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.
{
"error": {
"code": "unsupported_capability",
"message": "Prices are not available on testnets.",
"retryable": false
}
}| Field | Required | Description |
|---|---|---|
| code | Yes | Stable machine code. Use it in application logic. |
| message | Yes | Human-readable text. It may be replaced with a generic message, so do not parse it. |
| retryable | Yes | Whether the same request can be retried safely with backoff |
SDK properties
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);
}
}| Field | Required | Description |
|---|---|---|
| err.code | Yes | string |
| err.message | Yes | string |
| err.retryable | Yes | boolean |
| err.httpStatus | Yes | number |
| err.cause | No | Optional 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[].