Yes, that’s a good point. One of the things I like about with/1 is that it avoids nesting, but particularly if there are only one or two errors to handle, case could be the way to go (or if!).
with also lets me kind of replicate a pattern I like in imperative languages (eg. ruby):
shoes = get_shoes()
raise DressCodeError, "no shoes!" if shoes.nil?
shirt = get_shirt()
raise DressCodeError, "no shirt!" if shirt.nil?
This pattern of returning/raising as soon as possible also helps avoid a bunch of indentation, and means the function generally stays on the “happy path”.


















