Permalink
Browse files

Merge pull request #220 from andrew/rescue-cleanup

Cleaned up methods that rescue from response errors
  • Loading branch information...
2 parents fd930c6 + 2aa28fa commit 4c4da6cbbf224fbc6affa5e044f55c43bb70619d @pengwynn pengwynn committed Feb 10, 2013
Showing with 12 additions and 20 deletions.
  1. +9 −15 lib/octokit/client/notifications.rb
  2. +3 −5 lib/octokit/client/users.rb
View
24 lib/octokit/client/notifications.rb
@@ -81,11 +81,9 @@ def repository_notifications(repo, options={})
# @example
# @client.mark_notifications_as_read
def mark_notifications_as_read(options={})
- begin
- request(:put, "notifications", options).status == 205
- rescue
- false
- end
+ request(:put, "notifications", options).status == 205
+ rescue Octokit::Error
+ false
end
# Mark notifications from a specific repository as read
@@ -110,11 +108,9 @@ def mark_notifications_as_read(options={})
# @example
# @client.mark_notifications_as_read("pengwynn/octokit")
def mark_repository_notifications_as_read(repo, options={})
- begin
- request(:put, "repos/#{Repository.new repo}/notifications", options).status == 205
- rescue
- false
- end
+ request(:put, "repos/#{Repository.new repo}/notifications", options).status == 205
+ rescue Octokit::Error
+ false
end
alias :mark_repo_notifications_as_read :mark_repository_notifications_as_read
@@ -149,11 +145,9 @@ def thread_notifications(thread_id, options={})
# @example
# @client.mark_thread_as_ready(1, :read => false)
def mark_thread_as_read(thread_id, options={})
- begin
- request(:patch, "notifications/threads/#{thread_id}", options).status == 205
- rescue
- false
- end
+ request(:patch, "notifications/threads/#{thread_id}", options).status == 205
+ rescue Octokit::Error
+ false
end
# Get thread subscription
View
8 lib/octokit/client/users.rb
@@ -66,11 +66,9 @@ def access_token(code, app_id, app_secret, options = {})
# @option options [String] :password GitHub password
# @return [Boolean] True if credentials are valid
def validate_credentials(options = {})
- begin
- !self.class.new(options).user.nil?
- rescue Octokit::Unauthorized
- false
- end
+ !self.class.new(options).user.nil?
+ rescue Octokit::Unauthorized
+ false
end
# Update the authenticated user

0 comments on commit 4c4da6c

Please sign in to comment.