Built-In Exception Classes in Salesforce

Following are built in exceptions present in apex.

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.

InvalidParameterValueException – An invalid parameter was supplied for a method or any problem with a URL used with Visualforce pages.

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, and System.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.

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.

NoSuchElementException – Used specifically by the Iteratornext method. This exception is thrown if you try to access items beyond the end of the list. For example, if iterator.hasNext() == false and you call iterator.next(), this exception is thrown.

NullPointerException – Calling method on a object who’s value is null

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 APIsearch() call, for example, when the searchString parameter contains less than two characters.

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.

SObjectException – Any problem with sObject records, such as attempting to change a field in an update statement 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.

Gopal Das
Follow me

Gopal Das

Founder at GopalDas.Org
He is a technology evangelist, Salesforce trainer, blogger, and working as a Salesforce Technical Lead. After working in Java based project implementation, he jumped to the Salesforce system on a whim and never looked back. He fell in love with Salesforce’s flexibility, scalability, and power. He expanded his knowledge of the platform and became a Certified App Builder, Administrator, Platform Developer I, SalesCloud Consultant while leading the Salesforce implementation and technology needs. He has worked in a wide variety of applications/services like desktop, web and mobile applications.
Gopal Das
Follow me

Leave a Reply

Your email address will not be published. Required fields are marked *