Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleaned up methods that rescue from response errors

and only rescue from Octokit::Errors, rather than anything
  • Loading branch information...
commit 2aa28faa7b50253956f0b1e7df8d0408a9e2d49f 1 parent 75904d2
@andrew andrew authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.