Zulip Chat Archive

Stream: new members

Topic: convert option to except


Max Willsey (Nov 18 2025 at 16:34):

Hello, what are the idiomatic ways to convert an option to an except? I would like something like opt.toExcept errorPayload, but I can't find anything like that.

Eric Wieser (Nov 18 2025 at 16:52):

I guess opt.elim (.error errorPayload) .okprobably works, but I agree that a new function would probably make sense

Robin Arnez (Nov 18 2025 at 19:14):

opt.getDM (throw errorPayload) is the right thing to do here I believe

Max Willsey (Nov 18 2025 at 19:15):

@Robin Arnez yes! that's exactly what I was looking for. Thank you.

Eric Wieser (Nov 18 2025 at 19:15):

Perhaps docs#Except.toOption should mention that in the docstring


Last updated: Dec 20 2025 at 21:32 UTC