Before we talk about how to catch errors, let's talk about a result, because most errors don't require
the program to stop entirely.
And for these errors, we use the result type.
The result type is going to allow us to prepare in case there is a failure.
Most failures we can predict or account for so we can take some type of action to remediate these failures
without having the program.
Close.
Result is an enum that has two variants OC and air or and is defined like this.
So we have an enum called Result and has two generic variants, T and E.
And then in here we have OC, T and air or however you want to say it right there.
So that is the result.
Enum.
So a very common case that we can look at real quick is and I need to is opening a file.
So let's bring in the file into scope.
And then we can say.
Let file equal file open and remember these can fail.
So we'll just call it text, which obviously I have not created.
But if we hover over the open.
Method.
We can see that we are being returned.
A result.
So.
Now that we know that a result is returned in these possible scenarios, we can look at how to capture
these errors.