1 00:00:00,550 --> 00:00:08,380 So we just created a program that isn't going to air out, hopefully at least with Vallieres and Zero 2 00:00:08,500 --> 00:00:09,550 Division airs. 3 00:00:11,590 --> 00:00:19,090 But sometimes errors and exceptions can be so severe that we do want to stop our programs from running. 4 00:00:19,330 --> 00:00:26,830 We do want to catch them like this with the block, but at the same time also stop whatever the program 5 00:00:26,830 --> 00:00:27,310 is doing. 6 00:00:28,200 --> 00:00:34,180 Maybe instead of print, we actually want to display that red here and says, oh, something bad's happening. 7 00:00:34,200 --> 00:00:34,800 Stop that. 8 00:00:35,400 --> 00:00:42,720 Well, in that case, we either don't use the except block or in here we can say raise. 9 00:00:43,870 --> 00:00:44,890 Value air. 10 00:00:46,490 --> 00:00:49,010 Now, this is rare that you would have to do this. 11 00:00:49,550 --> 00:00:55,010 There are some specific use cases, but here you just write a message saying, hey. 12 00:00:55,960 --> 00:00:59,110 Cut it out so that if I run this. 13 00:01:01,100 --> 00:01:08,120 Well, if I type in a valid number, I get please enter a number, OK, I'm finally done because I raise 14 00:01:08,120 --> 00:01:09,020 a value error. 15 00:01:10,040 --> 00:01:20,150 And it throws in here into the book, so I'd have to remove this and if I remove this like this and 16 00:01:20,150 --> 00:01:20,720 hit Ron. 17 00:01:22,060 --> 00:01:29,950 And five and look at that, I get a value error, hey, cut it up so I'm able to throw my own eres. 18 00:01:32,320 --> 00:01:39,280 So this is really useful if you're creating your own library or tool and you want to let the user know 19 00:01:39,280 --> 00:01:42,120 that an error happened, I'm not going to keep doing what you're doing. 20 00:01:43,700 --> 00:01:49,910 And this could be any type of error, you can also do something like exception, and if I click run 21 00:01:49,910 --> 00:01:51,650 here, do five. 22 00:01:53,690 --> 00:01:55,110 I get an exception. 23 00:01:55,160 --> 00:01:56,000 Hey, cut it up. 24 00:01:57,810 --> 00:02:06,930 The key thing to remember with Ayres is that errors are unavoidable in programming, what your job is 25 00:02:06,930 --> 00:02:14,430 as a programmer is to be able to anticipate these errors, these bugs, these exceptions, and handle 26 00:02:14,430 --> 00:02:16,590 them properly in your programs. 27 00:02:17,460 --> 00:02:24,030 And some of the biggest errors happen when we're trying to accept input from a user not just using this 28 00:02:24,030 --> 00:02:33,090 input, but functions, accepting arguments, classes, accepting different inputs from users like method 29 00:02:33,090 --> 00:02:40,080 calls and trying to change attributes when the outside world in our programs try to communicate with 30 00:02:40,080 --> 00:02:40,530 each other. 31 00:02:40,890 --> 00:02:42,380 Errors are bound to happen. 32 00:02:42,600 --> 00:02:49,350 Our job as programmers is to try and code in a way that handles these exceptions gracefully and we can 33 00:02:49,350 --> 00:02:50,400 anticipate these. 34 00:02:50,420 --> 00:02:54,110 Sayres there's no such thing as a perfect program. 35 00:02:54,870 --> 00:03:01,830 However, we can try and do our best to learn from these errors and try to manage them so that our programs 36 00:03:02,040 --> 00:03:02,610 don't break. 37 00:03:03,620 --> 00:03:04,540 I'll see you in the next one.