• #31796
    Forcetalks

    What are the different types of Exceptions in Salesforce?

    What are the different types of Exceptions in Salesforce?

    Tagged: ,

    #31824
    #34587
    Salesforce | shariq shariq #1
    Forcetalks

    Hi,

    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.

    #36168
    Salesforce | Parul Parul #2
    Forcetalks

    List 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
    XmlException

     

    Thanks

Viewing 4 posts - 1 through 4 (of 4 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2018 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?