+ Start a Discussion

Show exception in UI

I need to show some generalised Error to user When I get some specific error.
The question is how to pass the caught Exception from Helper class to Trigger to show it to user and how to bulkify this.

Vipul TaylorVipul Taylor
You can use a custom exception class. ANd then in your code - use a try catch statement. Whenever you encounter an error 'throw' a new exception of the type CUSTOM_EXCEPTION  (the type that you will create) and then in the exception handler you can use ApexPages.addMessages() method to display the message on the page.

You can read more about exception handling here (https://developer.salesforce.com/page/An_Introduction_to_Exception_Handling)