Error Handling
The error
property in Wagmi Composables is strongly typed with it's corresponding error type. This enables you to have granular precision with handling errors in your application.
You can discriminate the error type by using the name
property on the error object.
vue
<script setup lang="ts">
import { } from 'wagmi'
const { , } = ()
?.
</script>
<template>
< v-if="?. === 'HttpRequestError'">
A HTTP error occurred. Status: {{ . }}
</>
< v-else-if="?. === 'LimitExceededRpcError'">
Rate limit exceeded. Code: {{ . }}
</>
</template>
ts
import { http, createConfig } from '@wagmi/vue'
import { mainnet, sepolia } from '@wagmi/vue/chains'
export const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
})