Throwing exceptions in case of database errors.