Error handling in server actions when same action is used by both client and server #75475
Unanswered
Undistraction
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
I am a little confused as to the correct way to handle errors that occur within server actions. If I have a server action, for example
doSomethingAction
that is used by both server components and client components, how should that action deal with errors, given that:When called from the server, it can be wrapped in a try/catch:
But when called from a client component it cannot be wrapped with a try/catch and needs to communicate the error through the response object:
Given these two different requirements (depending on where the actions is used), it seems that the same server action cannot be used on both client and server. Is this correct or am I missing something>?
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions