Created
February 21, 2014 01:21
-
-
Save amiel/9127033 to your computer and use it in GitHub Desktop.
Ignoring API errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class APIClient | |
def get_teapots | |
ignore_errors do | |
make_request :teapots | |
end | |
end | |
def get_coffeepots | |
ignore_errors do | |
make_request :coffeepots | |
end | |
end | |
private | |
def ignore_errors | |
yield | |
rescue *STUPID_ERRORS => e | |
# generic error handling | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment