Implemented handle of database exceptions.