Error handling.

maybe pull this out as a pcode validator function?