Defining custom exceptions gives you a powerfull way to handle errors from different sources in a standard way. In many cases, Exceptions are used to do some cleanup work, rollback to a certain state and/or do some error reporting.
To use this, simply define your own Exception and implement the wanted handling: