index/functions/toFailureView.md
toFailureView(
value):FailureView|undefined
Reads the failure view of any value: a GalaSDKError, or a plain object with a string code
(and, optionally, params, status, phase, uniqueKey, shadow, notFound). Anything else
(a string, a wallet error with a numeric code, null) has no view and is undefined.
Having a view does not mean the SDK knows the code: an ethers error is { code: 'ACTION_REJECTED' } and has a view too. The SDK's guards compare the code with the catalog.
failure view gala sdk error unique key not found action rejected
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
FailureView | undefined
failure view
Example
const view = toFailureView(error); // an SDK error, or an app's `{ code, params, status }` wrapper
if (view?.code === 'CHAIN_REJECTED') showChainRejection(view.params);