WEBVTT 00:00.490 --> 00:06.960 This lecture to talk about creating a user defined exception so all we have to do is create a class 00:07.050 --> 00:11.210 and then define some attribute or method that we want without exception. 00:11.490 --> 00:18.150 So let me create a class and think about exception then maybe I can use the exception. 00:18.360 --> 00:21.340 Sorry but at this point of time I'm just getting this. 00:21.340 --> 00:27.130 Then you can use coffee exception you can use my exception you can use any name of an exception. 00:27.240 --> 00:31.980 Basically it's not a Nimbin function and you can use any name. 00:32.010 --> 00:37.590 So let us use the exception and we need to have a base class that is the exception. 00:37.590 --> 00:40.880 So now we have created our own exception class. 00:40.900 --> 00:44.550 Now let me initiate some variables for my in it. 00:44.730 --> 00:51.930 And all I'm doing is taking an argument as message MSEE and also creating an object with self-taught 00:51.960 --> 00:54.150 MSE and passing this value. 00:54.150 --> 00:59.670 You can also use arguments but that would be more comfortable. 00:59.670 --> 01:00.470 This look fine. 01:00.480 --> 01:03.340 So I have created an exception class. 01:03.500 --> 01:06.240 I'll let me use my own exception here. 01:07.110 --> 01:09.340 But I'm not doing any major thing. 01:09.340 --> 01:11.990 I'm just taking this value. 01:12.130 --> 01:15.160 Let me run this one and see how this goes. 01:15.160 --> 01:19.190 Now you can see I got the exact result which I was expecting. 01:19.480 --> 01:25.780 So you can see I'm getting a genuine exception so that the sense I'm getting my men and I'm raising 01:25.780 --> 01:31.000 are the exception major quarter and then the messages the last two are. 01:31.120 --> 01:31.990 So that's fine. 01:32.020 --> 01:39.100 And it is working when we try to change the venue and give give us 50. 01:39.210 --> 01:43.230 I can see I'm getting an exception about these two call. 01:43.320 --> 01:44.260 So this looks fine. 01:44.280 --> 01:46.160 And this works really well. 01:47.110 --> 01:54.010 The best thing is we can play a lot more with our raise function so I can add more values I can add 01:54.010 --> 01:55.450 more messages here. 01:55.660 --> 02:01.690 And also I can create different exception class memory for these two Haught I can create different class 02:09.310 --> 02:13.700 so what I created two exception class and I'm using different. 02:13.710 --> 02:16.050 Exception with my different condition. 02:16.070 --> 02:23.610 So if it's above 85 I'm using different acception if it's below 65 I'm raising the exception and I tried 02:23.610 --> 02:25.200 to run this one. 02:25.410 --> 02:30.200 You can see I'm calling my the horn exception because it's 50. 02:30.340 --> 02:34.070 By now you already know we can create different exception classes. 02:34.070 --> 02:37.500 We can raise exception and we can use try except it. 02:37.510 --> 02:38.770 And finally. 02:38.770 --> 02:43.880 So that's all for our exception and hers and we can play a lot more thing. 02:44.020 --> 02:45.500 So this one is really important. 02:45.520 --> 02:51.230 I hope no understand about all the things regarding errors and how to run our buggy code that is how 02:51.790 --> 02:54.950 messy code with the help us try and fix a block. 02:55.390 --> 02:56.670 So that's on this one. 02:56.720 --> 03:00.160 And the next morning when be talking about a lot more thing with Python. 03:00.250 --> 03:02.930 So see you in the next one.