You need to sign in to do that
Don't have an account?
lvivanin
User defined Exception in apex class
How can we throw exception in Apex. I am trying do something like:
public class testExpt
{
public void exptTesting(Test_Object__c[] testObjectArray)
{
for (Test_Object__c t: testObjectArray)
{
if(t.test_field__c < 25.00)
{
throw new Exception('This is bad number');
}
}
}
}
How can I achieve this in Apex?
Hi,
Create a trivial class that extends Exception,
e.g.
{
}
then in your code, you can use:
throw new GeneralException('This is bad number');
All Answers
Hi,
Create a trivial class that extends Exception,
e.g.
{
}
then in your code, you can use:
throw new GeneralException('This is bad number');