-
Notifications
You must be signed in to change notification settings - Fork 0
The Soql.InvalidParameterValueException Class
Jason Siders edited this page Jul 4, 2025
·
5 revisions
This custom exception type decorates a standard System.InvalidParameterValueException thrown by the Database.Cursor class in certain circumstances, ex., when using a negative Integer in a fetch() call.
This is necessary since System.InvalidParameterValueException objects can only be manually constructed in VF or Aura contexts. Therefore, they cannot be mocked in apex tests.
Both Soql and MockSoql classes will throw this custom exception type instead of the standard Exception type:
try {
Soql.Cursor cursor = DatabaseLayer.Soql.newQuery(Account.SObjectType)?.getCursor();
cursor?.fetch(0, -1);
} catch (Soql.InvalidParameterValueException error) {
// Can't fetch a negative value!
}- Generating Test Records
- Dml
- Soql
- Cmdt
- Plugins
- DatabaseLayer
- Dml
- MockDml
- MockRecord
- Cmdt
- MockCmdt
- MockSoql
-
Soql
- Soql.AggregateResult
- Soql.Aggregation
- Soql.Binder
- Soql.Builder
- Soql.Condition
- Soql.ConditionalLogic
- Soql.Criteria
- Soql.Cursor
- Soql.Function
- Soql.InnerQuery
- Soql.InvalidParameterValueException
- Soql.LogicType
- Soql.NullOrder
- Soql.Operation
- Soql.Operator
- Soql.ParentField
- Soql.PreAndPostProcessor
- Soql.QueryLocator
- Soql.Request
- Soql.Scope
- Soql.Selectable
- Soql.SortDirection
- Soql.SortOrder
- Soql.Subquery
- Soql.TypeOf
- Soql.Usage
- Soql.WhenClause