You need to sign in to do that
Don't have an account?
parkerAPT
Can you catch a "Too many query rows" Exception ?
Is it possible to catch the exception thrown when there are too many query rows?
The following code does not catch any exception when there are more than 10,000 rows (500 in testCase) returned.
In this case, because it is a testMethod, the exception gets thrown because there are more than 500 rows returned.
static testMethod void testCatchTooManyRows(){
Boolean caught = false;
try{
Integer theCount = [SELECT count() from Contact];
}catch(Exception e){
caught = true;
}
System.assert(caught);
}
The following code does not catch any exception when there are more than 10,000 rows (500 in testCase) returned.
In this case, because it is a testMethod, the exception gets thrown because there are more than 500 rows returned.
static testMethod void testCatchTooManyRows(){
Boolean caught = false;
try{
Integer theCount = [SELECT count() from Contact];
}catch(Exception e){
caught = true;
}
System.assert(caught);
}
The system does not catch any errors thrown because there are no erros to be caught...
You are selecting an Integer that represents the number of rows to be retrieved. If you want to fire the exception try changing your code to something like this:
Your code does not compile.
The return type of "[SELECT count() from Contact]" is of type Integer, not List
Boolean caught = false;
try{
List<Contact_c> MyRecords = [SELECT ID from Contact];
} catch(Exception e){
caught = true;
}
System.assert(caught);
}
It seems that we can't catch these kinds of exception...
http://community.salesforce.com/sforce/board/message?board.id=apex&thread.id=7382