Detect intrinsic hookup failure during typechecking

Updated to use thread-local state for error return message.