print error more descriptive

This commit is contained in:
Petr Korolev 2015-05-18 09:26:36 +03:00
parent c67cbb31f2
commit 866c9f95d3

View File

@ -60,6 +60,21 @@ module GitHubChangelogGenerator
tags = [] tags = []
begin begin
github_fetch_tags(tags)
rescue Github::Error::Unauthorized => e
@logger.error e.body.red
@logger.error "Error: wrong github token provided".red
rescue Github::Error::Forbidden => e
@logger.warn e.body.red
unless @options[:token].nil?
@logger.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end
end
tags
end
def github_fetch_tags(tags)
response = @github.repos.tags @options[:user], @options[:project] response = @github.repos.tags @options[:user], @options[:project]
page_i = 0 page_i = 0
count_pages = response.count_pages count_pages = response.count_pages
@ -76,12 +91,6 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
elsif @options[:verbose] elsif @options[:verbose]
@logger.info "Found #{tags.count} tags" @logger.info "Found #{tags.count} tags"
end end
rescue
@logger.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end
tags
end end
# This method fetch all closed issues and separate them to pull requests and pure issues # This method fetch all closed issues and separate them to pull requests and pure issues
@ -108,6 +117,8 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
break if @options[:max_issues] && issues.length >= @options[:max_issues] break if @options[:max_issues] && issues.length >= @options[:max_issues]
end end
rescue rescue
puts e.message
puts e.backtrace.inspect
@logger.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow @logger.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end end