Skip to main content

Function: isShadowError()

gSwap SDK 2.0.0-rc.4


gSwap SDK 2.0.0-rc.4 / isShadowError

Function: isShadowError()

isShadowError(value): boolean

Defined in: packages/gswap-sdk/dist/index.d.ts:4231

True when value is a failure of the shadow (dark) path: an SDK error with shadow: true, a plain-object view of one ({ code, shadow: true }, see FailureView), or a non-SDK object (a requestor's own rejection) that escaped swapShadow, submitSwapShadow or ChainGateway.submitShadow. A primitive that was thrown (throw 'x') cannot be remembered, so it is never shadow; an app that cares tracks the call it made.

Parameters​

value​

unknown

Returns​

boolean

Example​

try {
await swaps.swapShadow('GALA', 'GUSDC', 3000, { exactIn: '100' });
} catch (error) {
const { retryable } = classifyFailure(error);
offerRetry(retryable && !isShadowError(error)); // never retry a dark swap in public
}