Use InvalidPluginExecutionException in plug-ins and workflow activities
Category: Supportability, Usability
Impact potential: Medium
If a synchronous plug-in returns an exception other than InvalidPluginExecutionException back to the platform, in a Power Apps client an error is displayed to the user with the message of the exception Message and the stack trace. This provides an unfriendly user experience in what is likely already a frustrating situation.
If you are using InvalidPluginExecutionException to intentionally cancel the operation because of data validation logic issue, you should provide guidance applicable to the application user so that they can correct the issue and continue.
If the error is unexpected, it is still recommended to catch the error and convert it into a InvalidPluginExecutionException so that applications can show a friendly error message with guidance to help a user or technical staff quickly identify the issue.
Plug-ins should only return an InvalidPluginExecutionException for the following reasons:
- Show a useful message to the user
- Avoiding event log/trace file bloat
Failure to convert the message into a InvalidPluginExecutionException will result in an
IsvUnExpected error with no message displayed to the user from a Power Apps client.
These patterns should be avoided.
Do not use HTML within error message text.
Web applications which access CDS data should HTML encode any error message text before they display it to a user. This will prevent any HTML in your message from rendered as you intend. It will just show the HTML code.