I have a struct that can throw an error.
If I just wanted to know if it had succeeded or not, I would use
But I want to catch the error so that I can give a useful message before terminating, and I don't think I can do/catch in a guard statement.. The best I can come up with is
That isn't as attractive in several ways. Is there a better way?
If I just wanted to know if it had succeeded or not, I would use
Code Block swift guard let try? thing = Thing() else { terminate }
But I want to catch the error so that I can give a useful message before terminating, and I don't think I can do/catch in a guard statement.. The best I can come up with is
Code Block swift let thing: Thing do try thing = Thing() catch ... { give useful message terminate }
That isn't as attractive in several ways. Is there a better way?