May 2019
Intermediate to advanced
546 pages
12h 41m
English
A custom exception is an exception written by a developer. This is an Apex class that extends the Exception class. We'll consider some more information about this class in a minute.
You cannot create an exception with the new keyword (such as throw new Exception()), but you need to extend this class and provide the error message you want via this extension. The following is an example of a custom exception. The name of this class needs to have a name that ends with Exception:
public with sharing class MyCustomException extends Exception { public MyCustomException(String sErrorCode, String sErrorMessage){ String theErrorMessage = sErrorCode + ': ' + sErrorMessage; this.setMessage(theErrorMessage); }}
Because this class is ...
Read now
Unlock full access