Created
July 26, 2018 22:36
-
-
Save SalesforceBobLightning/494fd5ebe19d75330b6dd1198f0232a3 to your computer and use it in GitHub Desktop.
Custom Salesforce Apex Exception With Constructor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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