Error handling is an essential part of every programming language. The general usage includes try, catch, and throw statements, but solidity uses require, revert, and assert methods to handle exceptions in the contract. Since Ethereum is a state machine, the exceptions that occur will revert all changes made to the state in the current call.
In this recipe, you will learn to handle exceptions using the require, revert, and assert methods.