1 00:00:07,670 --> 00:00:09,840 So let's not talk about exceptions. 2 00:00:10,500 --> 00:00:14,270 Well, you know, sometimes our court is producing killers and this is not good. 3 00:00:14,840 --> 00:00:17,780 We don't want to get unexpected errors in our court. 4 00:00:18,050 --> 00:00:25,670 We want always when we run the court to be sure that no matter what happens, we know what the error 5 00:00:25,670 --> 00:00:28,790 is or to expect what there is going to be. 6 00:00:30,660 --> 00:00:37,150 So let's see the following example, let's write items equals int. 7 00:00:39,410 --> 00:00:46,490 Inputs and then type a number of items. 8 00:00:47,970 --> 00:00:50,820 They right to print items. 9 00:00:50,970 --> 00:00:51,420 OK. 10 00:00:52,630 --> 00:00:57,670 Now, let's run this court and see what is basically going to happen, so now we're asking for a number 11 00:00:57,670 --> 00:00:58,240 of items. 12 00:00:58,240 --> 00:00:59,800 But here I will do something different. 13 00:00:59,920 --> 00:01:01,180 I will not put an integer. 14 00:01:01,180 --> 00:01:03,130 I'll put some string is. 15 00:01:04,120 --> 00:01:07,590 So if I run it now, you see that we are getting an error. 16 00:01:07,690 --> 00:01:11,830 And this is because the compiler was expecting that we were going to get. 17 00:01:12,750 --> 00:01:18,720 An integer, but what they actually sent to the function was a string, and for that reason we were 18 00:01:18,720 --> 00:01:19,800 getting a value error. 19 00:01:20,780 --> 00:01:23,300 And if you see this in red, this is not good. 20 00:01:23,510 --> 00:01:26,350 This means that there was something less vigilant protecting your gold. 21 00:01:26,720 --> 00:01:29,270 But how you can figure this in Bitel. 22 00:01:29,600 --> 00:01:33,060 So I will shift this coat and I write try. 23 00:01:33,570 --> 00:01:40,830 OK, so try means that we're trying to statement and then accept a volume error. 24 00:01:41,570 --> 00:01:47,360 So this means that if a value error appears, we're prepared. 25 00:01:47,600 --> 00:01:53,180 So we want to send a message to the user when a value error appears, maybe to give him some advice 26 00:01:53,180 --> 00:01:53,900 what he can do. 27 00:01:55,730 --> 00:01:57,320 So here are right to print. 28 00:01:57,680 --> 00:02:01,730 Your value is not on. 29 00:02:03,030 --> 00:02:03,720 Integer. 30 00:02:05,580 --> 00:02:07,770 So now if I run the code once again. 31 00:02:09,850 --> 00:02:16,680 And if I write the string here, then I'm not getting any Rowbottom advice that I need to put a value 32 00:02:16,960 --> 00:02:22,660 that is an integer, so my value that I put is actually an integer, and this is why it is not deceptive. 33 00:02:23,050 --> 00:02:26,530 But note here that this will not work for any type of federal. 34 00:02:26,720 --> 00:02:28,270 It work only for the value. 35 00:02:28,720 --> 00:02:29,300 OK. 36 00:02:29,320 --> 00:02:34,390 And if we see similar type of error, for example, total 30. 37 00:02:36,210 --> 00:02:40,440 So we showed this to me, the price per item, price per item. 38 00:02:41,790 --> 00:02:48,030 If this is a, quote, total divided by the number of items. 39 00:02:49,370 --> 00:02:58,370 So after you select print item and let's run this quote, so here, obviously if I select items to be 40 00:02:58,370 --> 00:03:01,880 zero, you know, division on zero, it's impossible. 41 00:03:01,910 --> 00:03:07,410 So if I do it, you see we're getting zero division error division by zero. 42 00:03:07,940 --> 00:03:10,180 And here again, we're receiving an error. 43 00:03:10,310 --> 00:03:11,120 And this is different. 44 00:03:11,660 --> 00:03:12,800 That's why we see it in the red. 45 00:03:13,190 --> 00:03:22,430 So in that case, we would like to create another exception so I can separate except and then you can 46 00:03:22,730 --> 00:03:28,370 copy and paste error there just to be sure that it is the exact error that you need to encounter. 47 00:03:28,760 --> 00:03:36,620 So now right print you can not divide by zero. 48 00:03:37,560 --> 00:03:39,960 OK, so if I run this again. 49 00:03:41,510 --> 00:03:46,630 And if I write a number of items to be equal to zero, you can see that now we're getting governments 50 00:03:46,790 --> 00:03:51,410 who cannot abide by Israel and why we need different exceptions for different errors. 51 00:03:51,590 --> 00:03:52,970 Well, this is simply because. 52 00:03:54,820 --> 00:03:58,360 There was a different solution to a different terror invasion, if issue is. 53 00:03:59,020 --> 00:04:03,940 It's not an integer four, is there a division error, then the user will not know what to do. 54 00:04:03,960 --> 00:04:04,300 Right. 55 00:04:05,540 --> 00:04:11,660 It is quite useful when you want sultry or cold very well, and basically create the courts that are 56 00:04:11,660 --> 00:04:12,350 error-free.