Custom plugin error handling – It’s very confusing situation for a Dynamics CRM plugin developer to identify errors without debug code. In this article we will dig it in detailed.
Display error message on CRM UI:
InvalidPluginExecutionException uses to display error messages in CRM UI which is used in catch block of custom plugin. Throw new InvalidPluginExecutionException(Message) is used to throw error from code and display on UI as popup in detailed.
InvalidPluginExecutionException can be thrown either from custom plugin class or main plugin class, from which all plugins are inherited.
For example you create PostAccountUpdate plugin and it must be inherited by main plugin class. So you need to add
throw new InvalidPluginExecutionException(ex.Message);
in catch session of plugin interface.