improve error reporting for invalid protocols

this greatly reduces confusion and simplifies tracing if there's a (usually silly, but non-obvious) error deep down the stack
Merge pull request #840 from FND/patch-1

improve error reporting for invalid protocols