Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Cleaned up methods that rescue from response errors #220

Merged
merged 1 commit into from

2 participants

@andrew

and only rescue from Octokit::Errors, rather than anything.

:octocat:

@andrew andrew Cleaned up methods that rescue from response errors
and only rescue from Octokit::Errors, rather than anything
2aa28fa
@pengwynn pengwynn merged commit 4c4da6c into octokit:master

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 9, 2013
  1. @andrew

    Cleaned up methods that rescue from response errors

    andrew authored
    and only rescue from Octokit::Errors, rather than anything
This page is out of date. Refresh to see the latest.
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
Something went wrong with that request. Please try again.