I'm a little confused about what you're doing here. It seems like you are trying to access the enrollment's mode to test to see if it exists before catching the exception, which will work, but I think it would be clearer that you're only testing for whether or not they're enrolled by using a simple `if` statement along with `CourseEnrollment.is_enrolled`.

(For historical context, we used to test for enrollment by seeing if the enrollment object existed, but we're moving away from that now. I think this is an artifact of those dark times.)