# When will getDataFromTree throw errors/how can I tell if errors were encountered?

**URL:** <https://community.apollographql.com/t/when-will-getdatafromtree-throw-errors-how-can-i-tell-if-errors-were-encountered/6848>\
**Category:** Client SDKs\
**Tags:** client, web\
**Created:** [October 17, 2023, 12:22am UTC](https://community.apollographql.com/t/when-will-getdatafromtree-throw-errors-how-can-i-tell-if-errors-were-encountered/6848 "2023-10-17T00:22:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![henryn](https://avatars.discourse-cdn.com/v4/letter/h/f14d63/32.png) [@henryn](https://community.apollographql.com/u/henryn)\
**Post date:** [October 17, 2023, 12:22am UTC](https://community.apollographql.com/t/when-will-getdatafromtree-throw-errors-how-can-i-tell-if-errors-were-encountered/6848/1 "2023-10-17T00:22:34Z")

</div>

Hi,  
I’d like a better understanding of getDataFromTree’s error policy and when I can expect it to throw errors. I’m trying to run getDataFromTree server-side in a NextJS app in getServerSideProps, and I think it might be hiding errors it encounters. The documentation doesn’t do a great job of explaining when I can expect getDataFromTree to throw an error (if ever). I guess what I’m asking - how can I get a good idea of whether my useQuery calls are returning errors during `getDataFromTree`? My default errorPolicy for my client is “All”.

Any help would be appreciated, thanks

---

<div class="post-metadata">

**Author:** ![lenz](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/lenz/32/4007_2.png) [@lenz](https://community.apollographql.com/u/lenz)\
**Post date:** [October 17, 2023, 8:01am UTC](https://community.apollographql.com/t/when-will-getdatafromtree-throw-errors-how-can-i-tell-if-errors-were-encountered/6848/2 "2023-10-17T08:01:00Z")

</div>

It doesn’t. Internally, it just renders your React component - and that will never throw an error to the outside.

At the end of it running, you’ll have the data of all successful queries, and in the worst case (I assume), it will have to make the other queries in the browser again.

---

<div class="post-metadata">

**Author:** ![henryn](https://avatars.discourse-cdn.com/v4/letter/h/f14d63/32.png) [@henryn](https://community.apollographql.com/u/henryn)\
**Post date:** [October 17, 2023, 6:52pm UTC](https://community.apollographql.com/t/when-will-getdatafromtree-throw-errors-how-can-i-tell-if-errors-were-encountered/6848/3 "2023-10-17T18:52:58Z")

</div>

So, effectively what your saying is that there is no way of telling if my `useQuery` hooks return errors during the execution of `getDataFromTree`?

---

<div class="post-metadata">

**Author:** ![jerelmiller](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/jerelmiller/32/3314_2.png) [@jerelmiller](https://community.apollographql.com/u/jerelmiller)\
**Post date:** [October 17, 2023, 8:01pm UTC](https://community.apollographql.com/t/when-will-getdatafromtree-throw-errors-how-can-i-tell-if-errors-were-encountered/6848/4 "2023-10-17T20:01:59Z")

</div>

Hey @henryn 👋

You should be able to look at the [`error`](https://www.apollographql.com/docs/react/api/react/hooks#error) property returned by `useQuery`, and if its populated, `throw` it yourself (if you want the throw behavior). See if that works for you!

---

<div class="post-metadata">

**Author:** ![Alexanderstrom](https://avatars.discourse-cdn.com/v4/letter/a/a88e57/32.png) [@Alexanderstrom](https://community.apollographql.com/u/Alexanderstrom)\
**Post date:** [February 5, 2024, 4:57pm UTC](https://community.apollographql.com/t/when-will-getdatafromtree-throw-errors-how-can-i-tell-if-errors-were-encountered/6848/5 "2024-02-05T16:57:31Z")

</div>

Hey!  
As stated above, it does not seem like any graphql errors is returned or thrown when running `getDataFromTree`. Ideally we would like to catch graphql errors server side so we can return a proper http response.

Say we’re rendering page `/todo/todo-dont-exist` which uses `useQuery` to fetch a todo. If the todo does not exist the error from `useQuery` would entail that. If that’s happening we would like to catch that so we could return a 404 server side. But this does not seem possible at the moment with `getDataFromTree` if I’m not missing anything?

If this is correct, would it be possible to add support for this, perhaps as an option to enable?

---

<div class="post-metadata">

**Author:** ![Justin\_Gonzalez](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/justin_gonzalez/32/5359_2.png) [@Justin\_Gonzalez](https://community.apollographql.com/u/Justin_Gonzalez)\
**Post date:** [February 6, 2025, 8:48pm UTC](https://community.apollographql.com/t/when-will-getdatafromtree-throw-errors-how-can-i-tell-if-errors-were-encountered/6848/6 "2025-02-06T20:48:13Z")

</div>


