diff options
| author | Jack Nagel | 2014-02-16 22:24:33 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-02-16 23:19:09 -0500 |
| commit | ea7415237c33744a00c6b27aebfa42416a0b01d1 (patch) | |
| tree | c74c8a55bc27a56e9429f7a0a7251a3453ae60e8 /Library/Homebrew/utils.rb | |
| parent | 3cbb49930c812b09c3fa8cd62fff8d722104e406 (diff) | |
| download | brew-ea7415237c33744a00c6b27aebfa42416a0b01d1.tar.bz2 | |
Add helpful error message for authentication failures
Diffstat (limited to 'Library/Homebrew/utils.rb')
| -rw-r--r-- | Library/Homebrew/utils.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 4bf9dbcc4..63eeff3fa 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -253,7 +253,6 @@ module GitHub extend self Error = Class.new(RuntimeError) HTTPNotFoundError = Class.new(Error) - AuthenticationFailedError = Class.new(Error) class RateLimitExceededError < Error def initialize(reset, error) @@ -274,6 +273,16 @@ module GitHub extend self end end + class AuthenticationFailedError < Error + def initialize(error) + super <<-EOS.undent + GitHub #{error} + HOMEBREW_GITHUB_API_TOKEN may be invalid or expired, check: + https://github.com/settings/applications + EOS + end + end + def open url, headers={}, &block # This is a no-op if the user is opting out of using the GitHub API. return if ENV['HOMEBREW_NO_GITHUB_API'] @@ -306,7 +315,7 @@ module GitHub extend self case e.io.status.first when "401", "403" - raise AuthenticationFailedError, e.message, e.backtrace + raise AuthenticationFailedError.new(e.message) when "404" raise HTTPNotFoundError, e.message, e.backtrace else |
