[ic] Cautious eval error handling
jon at endpoint.com
Sun Aug 23 01:09:01 UTC 2009
A few months ago I had an adventure tracking down a very obscure bug in
Interchange that was caused by a check for $@ too long after an eval was
called. The biggest reason it was hard to find was that even a logging
command had an eval that reset $@, making later checks fail. The fix was
That reinforces that it's good hygiene to only check $@ immediately after
the routine that sets it. And any routine expected to set it should
guarantee that it's cleared when there's no error.
I decided it would be good to go through the whole Interchange codebase
looking for any potential problems, and clean them up to save
troubleshooting and unexpected corner case failures later.
I'm only about halfway through and am committing most changes separately
so that they're small and have per-case explanations. I've pushed the work
so far to a new GitHub branch:
Many of the changes should make no difference at all right now, but could
prevent later problems and/or clarify the intent of the code.
Others change the way code checks for errors, trying to avoid $@. So far
the only functions I think are valid for setting $@ are eval, Safe's
reval, and Interchange's string_to_ref. When I come across others I'm
trying to have Interchange use the return code & whatever API exists
rather than rely on $@.
I'd appreciate any feedback or offers to help review & test, if any of you
End Point Corporation
More information about the interchange-users