function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
learn_cloudsflearn_cloudsf 

Error handling in apex

what is the sysntax for catching errors in apex ?
What is exception handling in apex ?
Dilip_VDilip_V
Exception:
An exception is a special condition that changes the normal flow of program execution.
Causes:
Your code expects a value from something that is currently null
An insert or update statement fails to pass a custom validation rule you have set
Assigning a query that returns no records or more than one record to a singleton sObject variable
Accessing a list index that is out of bounds
Syntax:
try{
     //Your code here
} catch (ListException e) {
     //Optional catch of a specific exception type
     //Specific exception handling code here
} catch (Exception e) {
     //Generic exception handling code here
} finally {
     //optional finally block
     //code to run whether there is an exception or not
}

for more information.

https://developer.salesforce.com/page/An_Introduction_to_Exception_Handling

If it helps make it as best answer.

Thanks.
 
Balaji BondarBalaji Bondar
Hi,

Please refer below link
https://developer.salesforce.com/page/An_Introduction_to_Exception_Handling

Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.