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