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

Custom Exception Message in apex Salesforce

i want to create a custom exception. In this Exception i want to make a constructor which take one string arguments and append in getMessage .How to accomplish this.

 public class TimelineException extends Exception{
  private String message;
    public override String getMessage(){
      return 'Not able to post to Timeline.getting response from Api : '+ message;

main problem i am facing is when i use this public TimelineException(Sting x){ } then its give me error

Save error: System exception constructor already defined: (String) GMirror.cls /Google Salesforce Integration/src/classes.


Is this nested inside another class?  I can't see why the error would refer to GMirror otherwise?


It sounds like you have put the constructor outside the class, but its difficult to say without seeing all of the code.