From 50a87241ed1b4ebe9bf5e57876fdfedd1ada6895 Mon Sep 17 00:00:00 2001 From: "Marc A. Paradise" Date: Wed, 28 Aug 2019 16:48:47 -0400 Subject: [PATCH] Ensure UserError is raised with a reason value This commit addresses the issue fixed in 416cf282c2f8c0bf4b0f5df818146bd6596323dd; however that commit discarded the reason attached to the exception. This should be kept, since Train::UserError covers a lot of ground and the reason code can help clients differentiate cause without resorting to their own parsing of error string. Signed-off-by: Marc A. Paradise --- lib/train/extras/command_wrapper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/train/extras/command_wrapper.rb b/lib/train/extras/command_wrapper.rb index b6e5f4f6..a7db5ab5 100644 --- a/lib/train/extras/command_wrapper.rb +++ b/lib/train/extras/command_wrapper.rb @@ -169,8 +169,8 @@ def self.load(transport, options) res = LinuxCommand.new(transport, options) verification_res = res.verify if verification_res - msg, _reason = verification_res - raise Train::UserError, "Sudo failed: #{msg}" + msg, reason = verification_res + raise Train::UserError.new("Sudo failed: #{msg}", reason) end res elsif transport.platform.windows?