- August 16, 2018 at 6:46 am #31796
What are the different types of Exceptions in Salesforce?
What are the different types of Exceptions in Salesforce?
August 16, 2018 at 10:17 am #31824Hi Avnish,
Please refer to the link provided:
Hope this helps.
September 16, 2018 at 5:36 pm #34587Hi,
AsyncException
Any problem with an asynchronous operation, such as failing to enqueue an asynchronous call.
CalloutException
Any problem with a Web service operation, such as failing to make a callout to an external system.
DmlException
Any problem with a DML statement, such as an insert statement missing a required field on a record.
EmailException
Any problem with email, such as failure to deliver. For more information, see Outbound Email.
ExternalObjectException
Any problem with external object records, such as connection timeouts during attempts to access the data that’s stored on external systems.
InvalidParameterValueException
An invalid parameter was supplied for a method or any problem with a URL used with Visualforce pages. For more information on Visualforce, see the Visualforce Developer’s Guide.
LimitException
A governor limit has been exceeded. This exception can’t be caught.
JSONException
Any problem with JSON serialization and deserialization operations. For more information, see the methods of System.JSON, System.JSONParser, andSystem.JSONGenerator.
ListException
Any problem with a list, such as attempting to access an index that is out of bounds.
MathException
Any problem with a mathematical operation, such as dividing by zero.
NoAccessException
Any problem with unauthorized access, such as trying to access an sObject that the current user does not have access to. This is generally used with Visualforce pages. For more information on Visualforce, see the Visualforce Developer’s Guide.
NoDataFoundException
Any problem with data that does not exist, such as trying to access an sObject that has been deleted. This is generally used with Visualforce pages. For more information on Visualforce, see the Visualforce Developer’s Guide.
NoSuchElementException
This exception is thrown if you try to access items that are outside the bounds of a list. This exception is used by the Iterator next method. For example, ifiterator.hasNext() == false and you call iterator.next(), this exception is thrown. This exception is also used by the Apex Flex Queue methods and is thrown if you attempt to access a job at an invalid position in the flex queue.
NullPointerException
Any problem with dereferencing null, such as in the following code:1
String s;
s.toLowerCase(); // Since s is null, this call causes
// a NullPointerException
QueryException
Any problem with SOQL queries, such as assigning a query that returns no records or more than one record to a singleton sObject variable.
RequiredFeatureMissing
A Chatter feature is required for code that has been deployed to an organization that does not have Chatter enabled.
SearchException
Any problem with SOSL queries executed with SOAP API search() call, for example, when the searchString parameter contains less than two characters. For more information, see the SOAP API Developer Guide.
SecurityException
Any problem with static methods in the Crypto utility class. For more information, see Crypto Class.
SerializationException
Any problem with the serialization of data. This is generally used with Visualforce pages. For more information on Visualforce, see the Visualforce Developer’s Guide.
SObjectException
Any problem with sObject records, such as attempting to change a field in an updatestatement that can only be changed during insert.
StringException
Any problem with Strings, such as a String that is exceeding your heap size.
TypeException
Any problem with type conversions, such as attempting to convert the String ‘a’ to an Integer using the valueOf method.
VisualforceException
Any problem with a Visualforce page. For more information on Visualforce, see the Visualforce Developer’s Guide.
XmlException
Any problem with the XmlStream classes, such as failing to read or write XML.The following is an example using the DmlException exception:
Account[] accts = new Account[]{new Account(billingcity = ‘San Jose’)};
try {
insert accts;
} catch (System.DmlException e) {
for (Integer i = 0; i < e.getNumDml(); i++) {
// Process exception here
System.debug(e.getDmlMessage(i));
}
}Hope this helps.
September 21, 2018 at 10:05 pm #36168List of possible exception:
Here they are:
AsyncException
CalloutException
DmlException
EmailException
ExternalObjectException
InvalidParameterValueException
LimitException
JSONException
ListException
MathException
NoAccessException
NoDataFoundException
NoSuchElementException
NullPointerException
QueryException
RequiredFeatureMissing
SearchException
SecurityException
SerializationException
SObjectException
StringException
TypeException
VisualforceException
XmlExceptionThanks
- AuthorPosts
Home Salesforce Questions & Answers Salesforce Questions and Answers What are the different types of Exceptions in Salesforce?
Related Salesforce Questions
- 1How can I rolled back my class when it runs into exception in salesforce?
- 3Error while inserting the feedItem in Salesforce
- 1What is the reason to skip the DML Operation on Empty List?
- 1Has anyone faced this issue "DeleteRestrictedByFkException not found in section Exception"?
- 2What are various standard exceptions that salesforce throws?
- 1Can we use try and catch exception in Lightning controller?
- 1I am facing issues in saving data in sandbox between 4-6 PM. This happens regularly. Any suggestion?
- 2How can we navigate from one component to another component in Salesforce?
- 1What is the difference between Process builder’s submit for approval and Approval processes in salesforce?
- 1Which Salesforce objects can be imported by Import Wizard?
- 1How can I enable Site.com Studio?
- 5Why we have to delete all records before creating a Master Detail relationship in a Master?
Salesforce Question Tags
- Salesforce Apex x 573
- Salesforce Development x 435
- Salesforce Visualforce Page x 432
- Salesforce SOQL x 298
- Salesforce Records x 287
- Salesforce Visualforce x 256
- Salesforce Customization x 217
- Salesforce Lightning x 211
- Salesforce Trigger x 189
- Salesforce Apex Code x 183
- Salesforce Apex Class x 159
- Salesforce Lightning Components x 159
- Difference x 151
- Salesforce Force.com x 149
- Salesforce Objects x 148
- active 1 hour, 59 minutes ago
- active 5 hours, 14 minutes ago
- active 18 hours, 30 minutes ago
- active 19 hours, 5 minutes ago
- active 20 hours, 33 minutes ago