why
Returns the reason for an interaction failure.
Import
You can import the entire package and access the function:
_10import * as sdk from "@onflow/sdk"_10_10sdk.why(ix)
Or import directly the specific function:
_10import { why } from "@onflow/sdk"_10_10why(ix)
Usage
_10import { Bad, why, initInteraction } from "@onflow/sdk"_10_10const interaction = Bad(initInteraction(), "Network timeout");_10console.log(why(interaction)); // "Network timeout"_10_10// Used with error handling_10if (isBad(response)) {_10 console.error("Error occurred:", why(response));_10}
Parameters
ix
- Type:
Interaction
- Description: The interaction to get the failure reason from
Returns
string