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.
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’);
// Process exception here