I would like to create a block of code that is not allowed to raise an exception. Is this possible?
My use case is that I have a block of code that fetches content from a 3rd party service and merges it into my main index. I don't want my application to be dependent on this 3rd party service in the event that it is down, or changes response format, etc., so how can I make a block of code that simply is not allowed to raise an error? I know I could do the following, but it seems unclean and my editor gives me
def index
@events = current_user.events
begin
other_events = get_content_from_3rd_party_api
@events.concat(other_events)
@events.sort! { |a, b| b.created_at <=> a.created_at }
rescue
end
end
or
def index
@events = current_user.events
other_events = get_content_from_3rd_party_api
@events.concat(other_events)
@events.sort! { |a, b| b.created_at <=> a.created_at }
rescue
end
but those both seem unclean