Function: isGSwapError
Call Signature
isGSwapError(
value):value is AnyGSwapError
True when value is an SDK error a gswap flow can throw and, when code is given, carries
exactly that code. With a code, error.params narrows to that code's params.
It recognises every GalaSDKError (instanceof), not only a GSwapSDKError: the signing,
transport and wallet failures of a gswap flow come from @gala-chain/gala-core-sdk (a signer,
the fetch requestor), carry a core code, and are core GalaSDKErrors. For such an error the
fields are exactly a GSwapSDKError's (notFound differs only for the DEX not-found codes,
which core never throws), so the narrowing holds for everything a gswap flow throws.
any swap error gala sdk not found
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
value is AnyGSwapError
any swap error
Example
if (isGSwapError(error, 'NON_CANONICAL_PAIR')) {
t('errors.NON_CANONICAL_PAIR', error.params); // { token0, token1 }
}
Call Signature
isGSwapError<
C>(value,code):value is GSwapSDKError<C>
True when value is an SDK error a gswap flow can throw and, when code is given, carries
exactly that code. With a code, error.params narrows to that code's params.
It recognises every GalaSDKError (instanceof), not only a GSwapSDKError: the signing,
transport and wallet failures of a gswap flow come from @gala-chain/gala-core-sdk (a signer,
the fetch requestor), carry a core code, and are core GalaSDKErrors. For such an error the
fields are exactly a GSwapSDKError's (notFound differs only for the DEX not-found codes,
which core never throws), so the narrowing holds for everything a gswap flow throws.
swap sdk error gala not found
Type Parameters
| Type Parameter |
|---|
C extends GSwapErrorCode |
swap error code
Parameters
| Parameter | Type |
|---|---|
value | unknown |
code | C |
Returns
value is GSwapSDKError<C>
swap sdk error
Example
if (isGSwapError(error, 'NON_CANONICAL_PAIR')) {
t('errors.NON_CANONICAL_PAIR', error.params); // { token0, token1 }
}