Improve invalid ruleref error message

Provide a description of the missing ref rather than giving a
<TypeError: can't dup NilClass> Exception.