ParserFile: config failure line number

This commit is contained in:
Olle Jonsson 2016-03-19 15:18:20 +01:00
parent 2e8e2a62e1
commit 29b5ef3d53

View File

@ -21,17 +21,17 @@ module GitHubChangelogGenerator
# Set @options using configuration file lines. # Set @options using configuration file lines.
def parse! def parse!
return unless @file return unless @file
@file.each_line { |line| parse_line!(line) } @file.each_with_index { |line, i| parse_line!(line, i + 1) }
@file.close @file.close
end end
private private
def parse_line!(line) def parse_line!(line, line_number)
option_name, value = extract_pair(line) option_name, value = extract_pair(line)
@options[option_key_for(option_name)] = convert_value(value, option_name) @options[option_key_for(option_name)] = convert_value(value, option_name)
rescue rescue
raise ParserError, "Config file problem on line \"#{line.gsub(/[\n\r]+/, '')}\"" raise ParserError, "Config file parsing failed on line ##{line_number}: \"#{line.gsub(/[\n\r]+/, '')}\""
end end
# Returns a the option name as a symbol and its string value sans newlines. # Returns a the option name as a symbol and its string value sans newlines.