Alter error object returned from queries
Hi there!
I'm trying to implement localized errors, by throwing errors from the server containing translation keys. Currently I just have a custom hook, like
I'm wondering if it is possible to configure the QueryClient in a way so that all my queries are automatically returning a new property like,
Or do I have to go with the other more manual solution which would probably be to create a custom hook for each query/mutation like
I'm trying to implement localized errors, by throwing errors from the server containing translation keys. Currently I just have a custom hook, like
useErrorMessage (see attached image) for handling this.I'm wondering if it is possible to configure the QueryClient in a way so that all my queries are automatically returning a new property like,
I18nErrorMessage, that is the result of running my custom hook?Or do I have to go with the other more manual solution which would probably be to create a custom hook for each query/mutation like
useBooksQuery and inside that custom hook I use my useErrorMessage hook and return the translated message together with the query itself?