Skip to content

Instantly share code, notes, and snippets.

@azuby
Created February 21, 2012 23:03
Show Gist options
  • Save azuby/1879653 to your computer and use it in GitHub Desktop.
Save azuby/1879653 to your computer and use it in GitHub Desktop.
def get_location
response = get_location_response
if response.success?
if status = response.to_array(:return, :location_response, :status).first == "FOUND"
return response
elsif error = response.to_array(:return, :msisdn_error).first
raise LocationError, error[:error_message]
raise APIError, "A problem was encountered with the API response: #{response.inspect}"
else
raise APIError, "A problem was encountered with the API response: #{response.inspect}"
end
else
raise APIError, "Connection to API unsuccessful: #{response.inspect}"
end
end
class Locator
@queue = :location_queue
def self.perform
begin
location = get_location
# do something useful with location
rescue LocationError => error
# do something useful with location error
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment