Free Salesforce Developers Tutorials >

Chapter 10 - Exception Handling >

Exceptional Handling in APEX

Exceptional Handling in APEX

What You’ll Learn

S2 Labs

What Is Exception Handling In Apex?

An exception denotes an error or event that disrupts the normal flow of code execution. Exception disrupts the normal flow of the application hence to keep the application running we use exception handling.

Exception handling is the process of responding to exceptions that appear in the code during its runtime so that the normal flow of the application can be maintained.

Example Of Exceptional Handling In Apex

DML statements return run-time exceptions if something goes wrong in the database during the execution of DML operations. 

You can handle the exceptions in your code by wrapping your DML statements within try-catch blocks. 

The following example includes the insert DML statement inside a try-catch block:

Account a = new Account(Name = 'Acme');
try {
    insert a;
} catch (DmlException e) {
    // Process exception here 



Download Study Material

Get access to exclusive study material for Salesforce Certification and ace your exams!

Download Now

Our Salesforce Certification Courses

Hey there! Glad you made it through our Salesforce Developer Training for beginners . But wait! We've got some high-in-demand Salesforce courses for you to take your Salesforce skills to the next level, making you a desired professional in the Salesforce job market.

Post a Comment

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