Include error message on failure

This commit is contained in:
Donal McBreen
2024-04-03 10:36:32 +01:00
parent 5e492ecc4d
commit 67a2d5e7ca
2 changed files with 4 additions and 3 deletions

View File

@@ -158,8 +158,8 @@ module Kamal::Cli
say "Running the #{hook} hook...", :magenta say "Running the #{hook} hook...", :magenta
run_locally do run_locally do
execute *KAMAL.hook.run(hook, **details, **extra_details) execute *KAMAL.hook.run(hook, **details, **extra_details)
rescue SSHKit::Command::Failed rescue SSHKit::Command::Failed => e
raise HookError.new("Hook `#{hook}` failed") raise HookError.new("Hook `#{hook}` failed:\n#{e.message}")
end end
end end
end end

View File

@@ -51,7 +51,8 @@ class CliBuildTest < CliTestCase
test "push pre-build hook failure" do test "push pre-build hook failure" do
fail_hook("pre-build") fail_hook("pre-build")
assert_raises(Kamal::Cli::HookError) { run_command("push") } error = assert_raises(Kamal::Cli::HookError) { run_command("push") }
assert_equal "Hook `pre-build` failed:\nfailed", error.message
assert @executions.none? { |args| args[0..2] == [ :docker, :buildx, :build ] } assert @executions.none? { |args| args[0..2] == [ :docker, :buildx, :build ] }
end end