function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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 (