Exception: GitHub::API::AuthenticationFailedError Private

Inherits:
Error
  • Object
show all
Defined in:
utils/github/api.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Error when authentication fails.

Instance Attribute Summary

Attributes inherited from Error

#github_message

Instance Method Summary collapse

Constructor Details

#initialize(github_message) ⇒ AuthenticationFailedError

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns a new instance of AuthenticationFailedError.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'utils/github/api.rb', line 65

def initialize(github_message)
  @github_message = github_message
  message = +"GitHub API Error: #{github_message}\n"
  message << if Homebrew::EnvConfig.github_api_token
    <<~EOS
      HOMEBREW_GITHUB_API_TOKEN may be invalid or expired; check:
        #{Formatter.url("https://github.com/settings/tokens")}
    EOS
  else
    <<~EOS
      The GitHub credentials in the macOS keychain may be invalid.
      Clear them with:
        printf "protocol=https\\nhost=github.com\\n" | git credential-osxkeychain erase
      #{CREATE_GITHUB_PAT_MESSAGE}
    EOS
  end
  super message.freeze
end