Skip to main content

why

Returns the reason for an interaction failure.

Import

You can import the entire package and access the function:


_10
import * as sdk from "@onflow/sdk"
_10
_10
sdk.why(ix)

Or import directly the specific function:


_10
import { why } from "@onflow/sdk"
_10
_10
why(ix)

Usage


_10
import { Bad, why, initInteraction } from "@onflow/sdk"
_10
_10
const interaction = Bad(initInteraction(), "Network timeout");
_10
console.log(why(interaction)); // "Network timeout"
_10
_10
// Used with error handling
_10
if (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


Rate this page