I'm testing out the Fullcontact API to retrieve information about specific people. If the person that I'm looking up with their API doesn't exist in their database it would return a 404 Not found error. I'm trying to get around that by retrieving other usernames, but it's not working. Here's the code:
person = FullContact.person(email: '[email protected]')
if person.to_i > 400
person = FullContact.person(email: '[email protected]')
else
person = FullContact.person(email: '[email protected]')
end
p person
This still displays the 404 Not found when the email isn't found.
If you're using the
fullcontact-api-rubygem, theFullContact.personcall should raise aFullContact::NotFounderror if the person doesn't exist. You'd need to rescue that error to try something else:Note that exceptions are pretty slow in Ruby, and you're also hitting an external API, so be mindful of the response time here.