Error handling

Global Error Handler

Set a global error handler on YieldProvider to catch errors from all action hooks:

<YieldProvider onError={(error) => {
  // Log to your error tracking service
  Sentry.captureException(error)
  toast.error(error.message)
}}>
  {children}
</YieldProvider>

Per-Hook Error Handling

Each action hook (useDeposit, useRedeem, useApprove) accepts local onError callbacks:

const { deposit, error } = useDeposit({
  vault: 'yoETH',
  onError: (err) => {
    toast.error(`Deposit failed: ${err.message}`)
  },
})

Both the local and global handlers are called when an error occurs.

Error States in Read Hooks

Read hooks expose isError and error fields:

API Errors

The ApiClient throws ApiError with an HTTP status code:

Common Errors

Error
Cause
Solution

"Client not available"

Hook used before providers are ready

Ensure YieldProvider is inside WagmiProvider

"Account not connected"

Action called without wallet connection

Check useAccount() before calling actions

"WalletClient is required"

Core client used for tx without wallet

Call client.setWalletClient() first

User rejected transaction

User declined in wallet

Catch and show appropriate UI