The perl regular expression (PCRE) in this case is a string into which several variables (macros) are injected. These components can be defined or not, and I can provide a default if the values are undefined in the configuration; ideally a notation to cause the expression to fail to evaluate, which will be reported back to the user. Unfortunately this is the logic I have to work with and can not change.
My current solution is to use an unmatched bracket with some error info, i.e. "(Undefined-Macro". I would prefer something explicit, but would appreciate any other suggestions that are less likely to break if the regular expression the components are being injected into already have missing brackets.
It's really hard to be certain that any given string will be a syntax error, because so much depends on what came before. Your mismatched parenthesis is an adequate sort of hack, but if you want an alternative, try something like "\p:Error message". The "\p" notation requires a single character or open brace to follow, so the colon triggers a syntax error — if it's being interpreted as a "\p" pattern in whatever context it lands, of course.