Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save SalesforceBobLightning/494fd5ebe19d75330b6dd1198f0232a3 to your computer and use it in GitHub Desktop.

Select an option

Save SalesforceBobLightning/494fd5ebe19d75330b6dd1198f0232a3 to your computer and use it in GitHub Desktop.
Custom Salesforce Apex Exception With Constructor
private class CustomExceptionWithConstructor extends Exception {
Private Object obj;
public CustomExceptionWithConstructor(Object obj){
this.obj = obj;
}
public override String getMessage() {
List<String> args = new String[]{obj.property1, obj.property2};
return String.format('Custom exception message with multiple arguments: {0} and {1}', args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment