You need to sign in to do that
Don't have an account?
sduda
Throwing Exceptions?
How do I throw one of the system defined exception types?
it says: throw <ExceptionObject>
I've tried:
throw new StringException();
throw new System.StringException();
throw StringException;
It returns the error message:
Exception type cannot be constructed
Thanks
it says: throw <ExceptionObject>
I've tried:
throw new StringException();
throw new System.StringException();
throw StringException;
It returns the error message:
Exception type cannot be constructed
Thanks
you should be able to create your own exception (possibaly extending a system exception) and then create and throw it.
let us know how this works, i've not tried it (yet)
public class NotificationRecordException extends Exception {}
ex:
public class NotificationRecord {
public class NotificationRecordException extends Exception {}
public static void testException() {
throw new NotificationRecordException('There was an exception');
}
}
...... And then from another class's method:
try {
NotificationRecord.testException();
} catch ( NotificationRecord.NotificationRecordException e ) {
System.debug(e);
}