I actually had a pretty good look around for static analysis options to see if I could find anything that might help us out before I landed up with this approach.
so ... that's interesting. I'll need to do some checking and verify that it's effective on the actual problem I originally had, but if so, I shall proceed with kicking myself now.
Handily, the same thing can be used to detect PG_TRY() escapes.