Document GitHub.
This commit is contained in:
parent
843f2a19e4
commit
6e6e01a71f
@ -3,6 +3,9 @@
|
|||||||
require "tempfile"
|
require "tempfile"
|
||||||
require "uri"
|
require "uri"
|
||||||
|
|
||||||
|
# Helper functions for interacting with the GitHub API.
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
module GitHub
|
module GitHub
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
@ -15,10 +18,12 @@ module GitHub
|
|||||||
"https://github.com/settings/tokens/new?scopes=#{ALL_SCOPES.join(",")}&description=Homebrew",
|
"https://github.com/settings/tokens/new?scopes=#{ALL_SCOPES.join(",")}&description=Homebrew",
|
||||||
).freeze
|
).freeze
|
||||||
|
|
||||||
|
# Generic API error.
|
||||||
class Error < RuntimeError
|
class Error < RuntimeError
|
||||||
attr_reader :github_message
|
attr_reader :github_message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Error when the requested URL is not found.
|
||||||
class HTTPNotFoundError < Error
|
class HTTPNotFoundError < Error
|
||||||
def initialize(github_message)
|
def initialize(github_message)
|
||||||
@github_message = github_message
|
@github_message = github_message
|
||||||
@ -26,6 +31,7 @@ module GitHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Error when the API rate limit is exceeded.
|
||||||
class RateLimitExceededError < Error
|
class RateLimitExceededError < Error
|
||||||
def initialize(reset, github_message)
|
def initialize(reset, github_message)
|
||||||
@github_message = github_message
|
@github_message = github_message
|
||||||
@ -42,6 +48,7 @@ module GitHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Error when authentication fails.
|
||||||
class AuthenticationFailedError < Error
|
class AuthenticationFailedError < Error
|
||||||
def initialize(github_message)
|
def initialize(github_message)
|
||||||
@github_message = github_message
|
@github_message = github_message
|
||||||
@ -65,6 +72,7 @@ module GitHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Error when the API returns a validation error.
|
||||||
class ValidationFailedError < Error
|
class ValidationFailedError < Error
|
||||||
def initialize(github_message, errors)
|
def initialize(github_message, errors)
|
||||||
@github_message = if errors.empty?
|
@github_message = if errors.empty?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user