Skip to content
Source
Sign inSign up
TanStack/query

Add throw error for useMutation #19

Mergedgaetanboedec(GitHub profile, opens in a new tab)merged 1 commit intomaster fromrefs/pull/19/headmerged by tannerlinsley View on GitHub

When using useMutation Hook in an event handler like when you submit a form sometimes you want to be able to access errors response from the server inside the event like

<Form onSubmit={(values) => {
  try {
      await mutate({ title })
      // Todo was successfully created
    } catch (error) {
      // Uh oh, something went wrong
    }
}}>
...
</Form>

Because the error is not return like the response, was not able to access error message in a try/catch

    1. vercel[bot](GitHub profile, opens in a new tab)commented

      This pull request is being automatically deployed with ZEIT Now (learn more). To see the status of your deployment, click below or on the icon next to each commit.

    2. Good catch. This was definitely a regression.

    3. tannerlinsley merged thisd4be56d

    4. tannerlinsley closed this

    5. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 8d79fc5b2abe9dc22493c61d507cbef502f20b4a

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded<1sView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded1sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-04-01 11:21:32 UTC

Sign in to join this conversation.