Common Salesforce Apex Errors
Common Exceptions in System Namespace
- System.AsyncException - Any problem with an asynchronous operation.
- Future method cannot be called from a future or batch method
- The Apex job named already scheduled for execution
- System.CalloutException - Any problem with a Web service operation.
- Exceeded maximum time allotted for callout
- Read timed out
- System.DmlException - Any problem with a DML statement on a record.
- CANNOT_EXECUTE_FLOW_TRIGGER
- FIELD_INTEGRITY_EXCEPTION
- INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY
- INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST
- MIXED_DML_OPERATION
- RECORD_IN_USE_BY_WORKFLOW
- REQUIRED_FIELD_MISSING
- STRING_TOO_LONG
- TRANSFER_REQUIRES_READ
- UNAVAILABLE_RECORDTYPE_EXCEPTION
- UNABLE_TO_LOCK_ROW
- System.EmailException - Any problem with email
- System.FinalException - Any attempt to mutate a read-only collection or record such as an sObject in an after-update trigger, or a final variable.
- SObject row does not allow errors
- System.FlowException - Any problem with starting flow interviews from Apex.
- System.JSONException - Any problem with JSON serialization and deserialization operations.
- System.LimitException - A governor limit has been exceeded.
- Too many DML rows: 10001
- Apex heap size too large
- Reason : Salesforce enforces an Apex Heap Size Limit of 6MB for synchronous transactions and 12MB for asynchronous transactions.
- Debug Process : Identify the collection variables used in the method throwing the error. Identify the SOQL queries in the method throwing the error
- Resolution : Deallocate space from the collection variable as soon as it’s not needed. Wherever possible, iterate over the results from the SOQL query rather than saving it in a collection variable and then iterating over it (Note : Ensure not to increase the count of SOQL in cases where result from a single SOQL query may be used at multiple places)
- Too many SOQL queries: 201
- Apex CPU time limit exceeded
- System.ListException - Any problem with a list.
- List index out of bounds
- System.NullPointerException - Any problem with dereferencing null
- Attempt to de-reference a null object
- Argument cannot be null.
- System.QueryException - Any problem with SOQL queries.
- Non-selective query against large object type
- Aggregate query has too many rows for direct assignment, use FOR loop
- List has no rows for assignment to SObject
- System.SObjectException - Any problem with sObject records.
- Field is not writeable
- System.StringException - Any problem with Strings,
- System.TypeException - Any problem with type conversions.
Reference : https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_exception_methods.htm