Closed muezz closed 1 day ago
Hi, I suggest to check out shape errors to be able to throw in the 90% of the cases. You can put it in a procedure so it will be inherited by all child actions. For the cases you don't want to throw, you can return a custom error class to check for. With regards to checking for error, it is possible to make a wrapper function that unwraps the zsa response for you.
Looks interesting. I will look into it. Thanks.
I am in the process of replacing
trpc
in my codebase withzsa
. So far it has been great but I am noticing a trend.Whenever I have to use a server action in a server component, I have to do an unnecessary null check to satisfy the typescript overlords.
Here is the action:
Same applies to a server component as well. I hope you get the idea.
Am I misunderstanding something? If not, is there a way to get around this because it is very hectic to keep writing that condition.
In 90% of the cases, I end up rethrowing that error because I expect the user to end up in
error.tsx
. Even the other condition is not necessary for me. I'd rather just get the value if it is successful but that may be an anti-pattern for the package.