Python for Absolute Beginners Transcripts
Chapter: Error handling
Lecture: Stepping through errors in the debugger

Login or purchase this course to watch this video and the rest of the course contents.
0:00 I want to do one more thing to just make sure
0:01 that you're really getting in the feel for how
0:03 the control flow works when we hit these errors.
0:07 I'm going to set a breakpoint, right up here.
0:09 And I'm going to hit the debug button.
0:11 And I'm going to come in here, and we're going to step
0:12 either over or into our code.
0:15 So let's step over this, over this, we don't care
0:18 about the log stuff, we don't care about the header stuff.
0:21 And let's go into this load_rolls here, and first
0:23 I'm going to really quickly break this.
0:26 Let's see what's going to happen.
0:28 Let's hit this first, step into our code.
0:31 And this is fine, this is fine, this is fine.
0:34 We've opened it you can see, opened up to that file.
0:37 A little more info. But this, if we even step
0:40 into this, and go deep down into, into Python itself
0:44 and as we try to work through these steps
0:47 what's going to happen, this is going to hit
0:51 this line and go
0:52 broken! And now it stops, what is this?
0:54 No, nothing. Keep going.
0:56 And it's going to start going down through here.
0:58 And now this one is going to actually match this
1:00 and go in here so, it's not going to be so unexpected.
1:03 But it says we have this error, which we named je
1:06 no not surprising and off it goes.
1:09 And then it just exits and so it
1:10 picked one of those blocks and it went.
1:12 Put this back.
1:15 And let's debug it again.
1:17 This time, let's go through, over step over.
1:20 I'm not going to go until we start playing the game a little.
1:23 We'll go down and do that.
1:25 It wants my name I guess.
1:30 And I'm going to go in, and-whoops console.
1:35 I want to throw seven, now actually
1:37 I wanted to stop down here.
1:39 So I didn't step and do it correctly so
1:41 I have to set the breakpoint down here.
1:43 Which is fine, and get roll, and now my roll is
1:45 now let's say seven correctly.
1:48 So, I'm going to step over, and it's
1:50 going to print out the rolls.
1:51 Let's not do the breakpoint there, and right down to here.
1:54 It asks what our roll is, and it's going to be seven.
1:58 And now we're back here, and it got the word seven numeral.
2:02 It's gong to convert that successfully
2:03 I'm going to say it's fine and just going to return
2:05 it's not going to go into the errors
2:07 but it's good, comes down and it just keeps playing.
2:09 And off it goes.
2:10 I don't know if I won, but I'm going to find out
2:12 let's go down a little bit farther to see if I won.
2:14 I, think I won? Yes I took the round.
2:16 Alright let's go farther.
2:18 And now let me type in some junk, something broken.
2:23 So, broken. This is broken. It's fine.
2:27 It says it's not nothing, so everything's good.
2:29 But we're going to try this, and
2:30 it's going to first say, I'm going to start going up
2:33 till I find the first except, the first try-except block.
2:35 It just happens to be right here
2:37 it could be that main one as well.
2:39 So we're going to come over here and step.
2:41 Not going to work, so it goes straight here.
2:43 Handles the error, returns it up here
2:45 and it doesn't go all the way the main
2:47 but it says alright we dealt with it and
2:49 what we decided to do is return none for roll one
2:52 when something invalid was done.
2:54 So that way, we can trigger this bit of code
2:56 to just make us do it again.
2:58 So as you're exploring this error handling
2:59 be sure to use the debugger and step over and into
3:02 and out of your code to explore the flow of the errors
3:06 as you go through the program.