Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script fails if restaurant or meal doesn't exist #24

Open
ipwnponies opened this issue Apr 21, 2019 · 0 comments
Open

Script fails if restaurant or meal doesn't exist #24

ipwnponies opened this issue Apr 21, 2019 · 0 comments

Comments

@ipwnponies
Copy link
Collaborator

next() is used with no default, this will raise StopIteration if not matched:

mealpy/mealpy/mealpy.py

Lines 88 to 93 in a580ab5

def get_schedule_by_restaurant_name(self, restaurant_name, city_name):
restaurant = next(
i
for i in self.get_schedules(city_name)
if i['restaurant']['name'] == restaurant_name
)

The behaviour of early exit is fine (we can't fallback to another option if it's ambiguous). We probably want to default to None, do truthy check , then print a a friendlier message to the user or raise a more meaningful error. This will be useful in the future, to do something like email the user when their meal could not be booked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant