Added error handling for pagination errors.