I am writing a trigger in which I want to throw a custom exception to display only the exception message instead of all the details. I cannot use addError()
method because its not on trigger context variable, I am passing ids of records to the trigger handler method and fetching them again to use them, this is required for me as I am using same handler for 4 different SObjects.
The output that I am getting is as below
In the above exception thrown on the page, I just want to show error message as 'Other Sales Rep is not found for bundled Opportunity with Id 00kn0000003lKllAAE' instead of all other details.
Exception class,
public class TriggerException extends Exception {}
Code used to throw exception from trigger handler.
throw new TriggerException (
' Other Sales Rep is not found for bundled Opportunity with Id ' + currentOppLineItem.Id);
is there any way to achieve this?
Any type of help is much appreciated.