Skip to content

Commit

Permalink
Merge pull request #2067 from jordansissel/improvement/errors-not-exc…
Browse files Browse the repository at this point in the history
…eptions

Configuration problems should print errors, not stack traces.
  • Loading branch information
jordansissel authored Sep 12, 2024
2 parents 18e04a7 + e94f56c commit fd06d93
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/fpm/package/deb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class FPM::Package::Deb < FPM::Package
option "--compression", "COMPRESSION", "The compression type to use, must " \
"be one of #{COMPRESSION_TYPES.join(", ")}.", :default => "gz" do |value|
if !COMPRESSION_TYPES.include?(value)
raise ArgumentError, "deb compression value of '#{value}' is invalid. " \
raise FPM::Package::InvalidArgument, "deb compression value of '#{value}' is invalid. " \
"Must be one of #{COMPRESSION_TYPES.join(", ")}"
end
value
Expand Down Expand Up @@ -364,7 +364,7 @@ def extract_info(package)
version_re = /^(?:([0-9]+):)?(.+?)(?:-(.*))?$/
m = version_re.match(parse.call("Version"))
if !m
raise "Unsupported version string '#{parse.call("Version")}'"
raise FPM::InvalidPackageConfiguration, "Unsupported version string '#{parse.call("Version")}'"
end
self.epoch, self.version, self.iteration = m.captures

Expand Down Expand Up @@ -504,15 +504,15 @@ def output(output_path)
end
if attributes[:source_date_epoch] == "0"
logger.error("Alas, ruby's Zlib::GzipWriter does not support setting an mtime of zero. Aborting.")
raise "#{name}: source_date_epoch of 0 not supported."
raise FPM::InvalidPackageConfiguration, "#{name}: source_date_epoch of 0 not supported."
end
if not attributes[:source_date_epoch].nil? and not ar_cmd_deterministic?
logger.error("Alas, could not find an ar that can handle -D option. Try installing recent gnu binutils. Aborting.")
raise "#{name}: ar is insufficient to support source_date_epoch."
raise FPM::InvalidPackageConfiguration, "#{name}: ar is insufficient to support source_date_epoch."
end
if not attributes[:source_date_epoch].nil? and not tar_cmd_supports_sort_names_and_set_mtime?
logger.error("Alas, could not find a tar that can set mtime and sort. Try installing recent gnu tar. Aborting.")
raise "#{name}: tar is insufficient to support source_date_epoch."
raise FPM::InvalidPackageConfiguration, "#{name}: tar is insufficient to support source_date_epoch."
end

attributes[:deb_systemd] = []
Expand All @@ -525,7 +525,7 @@ def output(output_path)
elsif [".service", ".timer"].include?(extname)
name
else
raise ArgumentError, "Invalid systemd unit file extension: #{extname}. Expected .service or .timer, or no extension."
raise FPM::InvalidPackageConfiguration, "Invalid systemd unit file extension: #{extname}. Expected .service or .timer, or no extension."
end

dest_systemd = staging_path("lib/systemd/system/#{name_with_extension}")
Expand Down

0 comments on commit fd06d93

Please sign in to comment.