1 00:00:05,980 --> 00:00:14,170 Before we talk about how to catch errors, let's talk about a result, because most errors don't require 2 00:00:14,170 --> 00:00:16,270 the program to stop entirely. 3 00:00:16,480 --> 00:00:19,900 And for these errors, we use the result type. 4 00:00:19,930 --> 00:00:24,340 The result type is going to allow us to prepare in case there is a failure. 5 00:00:24,580 --> 00:00:31,270 Most failures we can predict or account for so we can take some type of action to remediate these failures 6 00:00:31,270 --> 00:00:32,650 without having the program. 7 00:00:33,300 --> 00:00:33,870 Close. 8 00:00:35,400 --> 00:00:43,080 Result is an enum that has two variants OC and air or and is defined like this. 9 00:00:43,080 --> 00:00:50,160 So we have an enum called Result and has two generic variants, T and E. 10 00:00:51,090 --> 00:01:00,990 And then in here we have OC, T and air or however you want to say it right there. 11 00:01:00,990 --> 00:01:02,550 So that is the result. 12 00:01:02,580 --> 00:01:03,180 Enum. 13 00:01:04,240 --> 00:01:13,400 So a very common case that we can look at real quick is and I need to is opening a file. 14 00:01:13,420 --> 00:01:19,480 So let's bring in the file into scope. 15 00:01:20,690 --> 00:01:22,190 And then we can say. 16 00:01:23,200 --> 00:01:28,780 Let file equal file open and remember these can fail. 17 00:01:28,780 --> 00:01:32,110 So we'll just call it text, which obviously I have not created. 18 00:01:33,190 --> 00:01:35,440 But if we hover over the open. 19 00:01:36,480 --> 00:01:37,140 Method. 20 00:01:37,140 --> 00:01:39,300 We can see that we are being returned. 21 00:01:39,300 --> 00:01:40,080 A result. 22 00:01:41,440 --> 00:01:42,160 So. 23 00:01:42,930 --> 00:01:52,020 Now that we know that a result is returned in these possible scenarios, we can look at how to capture 24 00:01:52,170 --> 00:01:53,100 these errors.