Add sanity checks for fact search

Prior to this commit if puppetdb was down, a cryptic error
would occur. This commit adds some logic around that