How do you return data while throwing an error? #365
Unanswered
mintydev789
asked this question in
Q&A
Replies: 1 comment 8 replies
-
Hey, I'm really curious to know how you used to add fields to the Error class, because as far as I know, React removes all additional fields to make the error serializable, so it can be sent to the client. You can find more information about this here: |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a custom error class I created for my server function errors, and I extended it with an optional
data
field for returning some data while throwing the error. This can be useful for cases where, for example, you want to return the user the updated state if the state they see in the browser is out-of-date, meaning that their original request should now be considered stale.Originally, this worked just fine, and I was able to access the full error object on the frontend, including the
data
field, but for some reason it no longer works for me on v8.0.2 (not sure if it's due to a recent update though). Is there a "proper" way for returning data when throwing errors in next-safe-action?Beta Was this translation helpful? Give feedback.
All reactions