The code you have there does in fact not work, because there is no block to yield
to.
You will get a LocalJumpError
, which gets swallowed by the catch-all rescue
, and thus it will look like there is a problem with the file, when in fact, there is actually a programming error. (Teachable moment: never ever do a blanket catch-all rescue
, always rescue only exactly those exceptions you want to handle.)
CLICK HERE to find out more related problems solutions.