diff --git a/lib/github_changelog_generator/parser_file.rb b/lib/github_changelog_generator/parser_file.rb index b8a77e2..df92814 100644 --- a/lib/github_changelog_generator/parser_file.rb +++ b/lib/github_changelog_generator/parser_file.rb @@ -1,4 +1,6 @@ module GitHubChangelogGenerator + ParserError = Class.new(StandardError) + class ParserFile def initialize(options) @options = options @@ -22,7 +24,7 @@ module GitHubChangelogGenerator value = false if value =~ (/^(false|f|no|n|0)$/i) @options[key_sym] = value rescue - raise "Config file #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\"" + raise ParserError, "Config file #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\"" end # Returns a the setting as a symbol and its string value sans newlines. diff --git a/spec/unit/parse_file_spec.rb b/spec/unit/parse_file_spec.rb index eb8af0c..6c59f78 100644 --- a/spec/unit/parse_file_spec.rb +++ b/spec/unit/parse_file_spec.rb @@ -20,7 +20,7 @@ describe GitHubChangelogGenerator::ParserFile do let(:options) { { params_file: "spec/files/github_changelog_params_incorrect" } } let(:options_before_change) { options.dup } let(:parse) { GitHubChangelogGenerator::ParserFile.new(options) } - it { expect { parse.parse! }.to raise_error } + it { expect { parse.parse! }.to raise_error(GitHubChangelogGenerator::ParserError) } end context "when override default values" do