Exception Errors Flashcards
AsyncException
Any problem with an asynchronous operation, such as failing to enqueue an asynchronous call.
BigObjectException
Any problem with big object records, such as connection timeouts during attempts to access or insert big object records.
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.
IllegalArgumentException
An illegal argument was provided to a method call. For example, a method that requires a non-null argument throws this exception if a null value is passed into the method.
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, 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 exception is 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 exception is 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, if iterator.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:
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 fewer 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 exception is 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 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.
Exceptions show errors and other events that disrupt the normal flow of code execution. Which of the following statements are true about Apex Exception Handling?
Choose 3
A. You can have multiple Catch blocks to catch all different kinds of exceptions. If you use a generic exception catcher, it must be the first Catch block.
B. The finally statement is required and gets executed after the catch block executes.
C. The try statement identifies a block of code in which an exception could occur.
D. The try statement identifies a block of code in which an exception could occur.
E. Comparatively, a throw statement allows you to signal that an error has occurred, while try, catch, and finally can be used to pull through from an exception
C. The try statement identifies a block of code in which an exception could occur.
D. The try statement identifies a block of code in which an exception could occur.
E. Comparatively, a throw statement allows you to signal that an error has occurred, while try, catch, and finally can be used to pull through from an exception
True or False
A finally block is required in a try, catch, finally statement
False
What does a throw statement do?
A throw statement allows you to signal that an error has occurred
Try-catch-finally statements are used to…
The try, catch, and finally statements can be used to gracefully recover from a thrown exception
what does the ‘try’ in a try-catch-finally statement do?
The try statement identifies a block of code in which an exception can occur.
what does the ‘catch’ in a try-catch-finally statement do?
The catch statement identifies a block of code that can handle a particular type of exception.
True or False
Each catch statement must have a unique exception type?
True
True or False
In try-catch-finally statements, once a particular exception type is caught in one catch block, the remaining catch blocks, if any, aren’t executed.
True
what does the ‘catch’ in a try-catch-finally statement do?
The finally statement identifies a block of code that is guaranteed to execute and allows you to clean up your code.
True or False
the finally block in a try-catch-finally statement only executes when an exception is thrown.
False
Code in the finally block always executes regardless of whether an exception was thrown or the type of exception that was thrown.