Added logging on database errors