Skip to main content

Function: chainErrorKeyOf()

gSwap SDK 2.0.0-rc.4


gSwap SDK 2.0.0-rc.4 / chainErrorKeyOf

Function: chainErrorKeyOf()

chainErrorKeyOf(error): string | undefined

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

The chain's own machine-readable ErrorKey of a failure ('TOKEN_NOT_FOUND', 'NOT_ENOUGH_LIQUIDITY', ...), for an app that maps a chain refusal to its own copy: the params.errorKey of a CHAIN_REJECTED (an apply result, or a body that carries the chain's error) and of a CHAIN_DISPATCH_FAILED (the gateway adds the chain's key to the body it answered). undefined when the failure is neither, or when it carries no key (the gateway sent none: the SDK writes '', which is not a key). Map the KEY, never the message text.

Accepts an SDK error or a plain-object view (FailureView: code and params); every other value is undefined. Other codes are undefined even when they have an errorKey-named param, so a stray field cannot pass for a chain verdict.

Parameters​

error​

unknown

Returns​

string | undefined

Example​

const key = chainErrorKeyOf(error);
if (key === 'NOT_ENOUGH_LIQUIDITY') showTooThin(); else showGeneric(error);