Another newbie question but I can't get my head around it.
I am following this documentation regarding how to handle concurrent updates.
I am setting up an User Exception in my server action similar to this one:
I have implemented point 3 with an exception message. Now I want to display this message to the final users via the message widget.
Is it possible to do it directly in the server action?
In the same documentation, there is a FeedbackMessage in the exception handler, but I don't see it in reactive applications.
Also, out of curiosity, how do you handle other server exceptions, do you display those horribly long error messages to users or customize them? If yes, how?
Thanks in advance for clarifying this aspect.
You need an exception handler in the screen action from which you are calling the server action, or the screen action that calls some action that calls the server action in the end. Also, you need a global exception handler to handle any exceptions that aren't handled in any screen action (but you likely already have that).
Hi Andrea,
It's a good practice to avoid using FeedbackMessages in Server Actions, because you do not know whether the consumer of the action is a user-facing application with a UI - for all you know it's a Timer, that then will never see something's wrong because you intercept the exception (and the error message via the FeedbackMessage will never show).
So, best practice is to either return an error code, or issue an exception (like in the example you showed). It's then up to the consumer to handle it, and also whether to rollback the transaction (this may not be desirable in every case).
As for the "horribly long error messages", yes, we generally display these to users, but our users are our colleagues - in case of our customers we'd rather display a general "something went wrong" error.
Thanks @Kilian Hekhuis for the explanation.
When you say "best practice is to either return an error code, or issue an exception" in my case I raise an exception in the server action, but I am missing how to display the message to the final user. I thought it would be displayed by default, but I don't see it.
All clear now, I had an exception handler inside the server action for all the exceptions that was just going directly to "End". I think it meant that any errors occurring inside the server action will only be logged and I want to show them to the user instead.
Now it works! Thank you for your help.
That's indeed what it means: once the End is reached, the exception is no longer visible to the caller of that action. Whether the exception is logged depends on the "Log Error" property of the Exception Handler.