#100DaysOfCode in Python Transcripts
Chapter: Days 25-27: Error handling
Lecture: Demo: The starter app skeleton

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's jump right into our demo here. Over in the GitHub repository, we're going to start with a movie search app.
0:08 And this is called "movie search error edition." Later, we're going to actually build this app from scratch.
0:14 We're going to talk about the underlying API and all that kind of stuff. Right now, we're just going to run it and try to solve
0:19 the errors that it might encounter. Now, there's two parts here: there's the starter, exactly where I'm starting from, and I'll leave this here,
0:25 in case you want to play with it. This one, we're going to involve into the final one. Now, before we open this up,
0:31 let's create a virtual environment, there we go, and I'm going to throw it into PyCharm, and use whatever editor you want. This is one we're using.
0:39 This one actually depends upon a package called "requests" So, if we come over here with our
0:45 virtual environment active, we can say pip install requests or you can just click this little hyperlink thing right there.
0:52 Either way, we're going to have to do that before this will run because that's how we're getting to the internet. So, here's how this program works.
0:59 Like I said, we're going to, in a different set of three days, we're going to build this thing from scratch and really focus on the API.
1:05 We don't actually care how the API works. All that matters is, we pass a keyword here, and it's going to go over to a service
1:12 over at movie_service.talkpython.fm. Do a search, get back some JSON data, and then return those here as results and we're going to loop over them.
1:22 Now, I've introduced some extra errors here, alright, sort of a chance of something going really, really wrong, just to give us some variety.
1:30 The most likely error you're going to run into is a network error. Let's just see if this runs correctly. How about "Capital?" Cool. There.
1:40 We've gotten three movies back and see their IMBD score right there. It looks like it's working, except for sometimes it's not.
1:48 It actually has these errors baked into it. But the one that we're definitely going to hit as we come over here, we turn off the wifi,
1:54 this won't be so good. So, now if I try to run this, let's see what we get. Test, maybe? Uh-huh. request.exceptions.connectionerror.
2:04 And what went wrong, the connection pool had some kind of problem. Max retries exceeded with URL, caused by ... We couldn't get to the server, right?
2:14 So we turned off the internet, it crashed. Instead, what we'd like to have happen is our program go, hey, couldn't get to the server.
2:22 Is your wifi off? Check your internet connection. Are you at a coffee shop? Then you have to maybe authenticate to the local network,
2:28 where you say you agree to their terms or whatever, right? So we want to catch these errors instead of having
2:33 this nasty crash and give a helpful message to the users.


Talk Python's Mastodon Michael Kennedy's Mastodon