Function: isGSwapError()
gSwap SDK 2.0.0-rc.4 / isGSwapError
Function: isGSwapError()
Call Signature
isGSwapError(
value):value is AnyGSwapError
Defined in: packages/gswap-sdk/dist/index.d.ts:1024
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.
Parameters
value
unknown
Returns
value is AnyGSwapError
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>
Defined in: packages/gswap-sdk/dist/index.d.ts:1025
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.
Type Parameters
C
C extends GSwapErrorCode
Parameters
value
unknown
code
C
Returns
value is GSwapSDKError<C>
Example
if (isGSwapError(error, 'NON_CANONICAL_PAIR')) {
t('errors.NON_CANONICAL_PAIR', error.params); // { token0, token1 }
}