Skip to main content

Error codes & SDK exceptions

On failure, the SDK throws GStableError or a subclass. Use isGStableError(err) for type narrowing.

Base class

PropertyMeaning
codeNumeric business or transport code; -1 often means network error before HTTP response.
messageHuman-readable; do not rely on exact English strings for branching.

createTypedApiError

When the API returns an envelope with code !== 0, the HTTP layer calls createTypedApiError(code, message):

ConditionThrown type
Product-range codes 100301–100306GStableProductError (productErrorCode duplicates code)
Known common / validation codes (400XXX in SDK constants)GStableCommonError
Known platform codes (900XXX / 999999)GStablePlatformError
OtherwiseGStableError

Product codes (ProductErrorCodes)

ConstantValueTypical meaning
NOT_FOUND100301Product ID does not exist.
PARTIAL_MISSING100302Batch: some IDs missing.
PARTIALLY_UNAVAILABLE100303Batch: some not usable.
NOT_ACTIVE100304Not active for link/session use.
HAS_BEEN_USED100305Blocked mutation due to usage.
HAS_BEEN_REMOVED100306Logically deleted.

Use isProductErrorCode(code), ProductErrorMessages (reference text only).

Common codes (CommonErrorCodes)

ConstantValue
INVALID_FIELD_FORMAT400101
UNSUPPORTED_CURRENCY400201
UNSUPPORTED_CHANNEL400202
SETTLEMENT_CAPABILITIES_NOT_FOUND400203
STAT_NOT_FOUND400301

Platform codes (PlatformErrorCodes)

ConstantValue
TOO_MANY_REQUESTS900101
FAILED_TO_CREATE_RECORD900201
FAILED_TO_UPDATE_RECORD900202
FAILED_TO_QUERY_RECORD900203
IMAGE_PROCESSING_FAILED900301
INTERNAL_SYSTEM_ERROR999999

HTTP / transport edge cases

  • Non-JSON body (HTML, WAF, proxy) → GStableError with descriptive message (403/401 helpers in SDK).
  • Invalid envelope on HTTP 200 → GStableError.

Official taxonomy

Full, authoritative tables live under API overview → Errors on docs.gstable.io.

Example — branch on product errors

import {
GStableClient,
isGStableProductError,
ProductErrorCodes,
} from 'gstable-js';

const client = new GStableClient({ apiKey: process.env.GSTABLE_API_KEY });

try {
await client.product.remove('prod_xxx');
} catch (e) {
if (isGStableProductError(e) && e.code === ProductErrorCodes.HAS_BEEN_USED) {
// handle “in use”
}
throw e;
}