On General Error

This is not particularly related to PilotScript, but it is a tip or trick. It's disappointing to see this forum empty, so...

(On a side note, it's a little confusing to have this topic's description say "scripts or subroutines" when PilotScript itself does not allow for subroutines.)

I want to write about the evil that is the On General Error setting. This setting is needed occasionally to handle errors that can't be otherwise recovered from. So, it's very useful, but its effect can be very sneaky, particularly when used on a subprotocol. I often end up wrapping my home-grown java components in subprotocols, because the On General Error setting is ignored on java components in 6.x. It's the only way I can get my protocol to continue if my java component has thrown an exception. The insidious nature of the problem occurs as I add more and more functionality into that subprotocol. If the new stuff generates an error inside that subprotocol, the error gets consumed by the On General Error setting and I don't see the immediate error. This often leads to very confusing behavior way downstream, since assumptions you make about a data record that's been affected by this can be totally incorrect. This problem used to bite me on a regular basis, but I've since been more disciplined. So, here's my tip:

Whenever you change the On General Error setting on a component, immediately add a sticky note to that component remarking on its changed On General Error setting.

I can almost promise that you will thank yourself many times over the moment you first discover a problem with your protocol.