lib/hexapdf/cli/command.rb in hexapdf-0.32.2 vs lib/hexapdf/cli/command.rb in hexapdf-0.33.0

- old
+ new

@@ -41,10 +41,13 @@ require 'hexapdf/font/true_type' module HexaPDF module CLI + # Raised when problems occur on the CLI side of things. + class Error < HexaPDF::Error; end + # Base class for all hexapdf commands. It provides utility methods needed by the individual # commands. class Command < CmdParse::Command module Extensions #:nodoc: @@ -132,11 +135,11 @@ def write_document(doc, out_file, incremental: false) if out_file doc.trailer.update_id doc.validate(auto_correct: true) do |msg, correctable, object| if command_parser.strict && !correctable - raise "Validation error for object (#{object.oid},#{object.gen}): #{msg}" + raise Error, "Validation error for object (#{object.oid},#{object.gen}): #{msg}" elsif command_parser.verbosity_info? $stderr.puts "#{correctable ? 'Corrected' : 'Ignored'} validation problem " \ "for object (#{object.oid},#{object.gen}): #{msg}" end end @@ -149,10 +152,10 @@ # Checks whether the given output file exists and raises an error if it does and # HexaPDF::CLI#force is not set. def maybe_raise_on_existing_file(filename) if !command_parser.force && File.exist?(filename) - raise "Output file '#{filename}' already exists, not overwriting. Use --force to " \ + raise Error, "Output file '#{filename}' already exists, not overwriting. Use --force to " \ "force writing" end end # Defines the optimization options.