lib/review/tocprinter.rb in review-5.2.0 vs lib/review/tocprinter.rb in review-5.3.0

- old
+ new

@@ -67,16 +67,21 @@ attr_accessor :calc_char_width def execute(*args) parse_options(args) - @config = ReVIEW::Configure.create(yamlfile: @yamlfile) - @book = ReVIEW::Book::Base.new('.', config: @config) - unless File.readable?(@yamlfile) - @logger.error("No such fiile or can't open #{@yamlfile}.") + begin + @config = ReVIEW::Configure.create(yamlfile: @yamlfile) + @book = ReVIEW::Book::Base.new('.', config: @config) + unless File.readable?(@yamlfile) + raise ReVIEW::FileNotFound, "No such fiile or can't open #{@yamlfile}." + end + rescue ReVIEW::ConfigError, ReVIEW::FileNotFound, ReVIEW::CompileError, ReVIEW::ApplicationError => e + @logger.error e.message exit 1 end + I18n.setup(@config['language']) if @detail begin require 'unicode/eaw' @@ -224,12 +229,12 @@ def calc_line_wrapping(line, mode:) return 1 if line.size == 0 case mode when :list - (calc_linesize(line) - 1) / @book.page_metric.list.n_columns + 1 + ((calc_linesize(line) - 1) / @book.page_metric.list.n_columns) + 1 else # mode == :text - (calc_linesize(line) - 1) / @book.page_metric.text.n_columns + 1 + ((calc_linesize(line) - 1) / @book.page_metric.text.n_columns) + 1 end end def calc_total_count(name, headline_array) total = Counter.new(name: name,