From 6fd0125ad9e2fc4eab2639f57136d8b15cffd744 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sun, 16 Feb 2014 22:24:33 -0500 Subject: [PATCH] Handle GitHub API authentication failures --- Library/Homebrew/utils.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index c6fe46a5ea..1377191dfb 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -254,6 +254,7 @@ module GitHub extend self Error = Class.new(StandardError) RateLimitExceededError = Class.new(Error) HTTPNotFoundError = Class.new(Error) + AuthenticationFailedError = Class.new(Error) def open url, headers={}, &block # This is a no-op if the user is opting out of using the GitHub API. @@ -288,6 +289,8 @@ module GitHub extend self end case e.io.status.first + when "401", "403" + raise AuthenticationFailedError, e.message, e.backtrace when "404" raise HTTPNotFoundError, e.message, e.backtrace else