diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-04-01 12:27:16 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-04-01 12:27:16 -0700 |
commit | 05ddd50f52b2350f99ef8b2b8138e069713fd609 (patch) | |
tree | e681b2a2aca15487146587925df3ea57c08a4b6a | |
parent | e7330a21ab6427d0820799bc0f79db39faa7b866 (diff) | |
download | chef-05ddd50f52b2350f99ef8b2b8138e069713fd609.tar.gz |
revert back to throwing Chef::Exceptions::Cron
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/provider/cron.rb | 7 | ||||
-rw-r--r-- | spec/functional/resource/cron_spec.rb | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb index bc1b1d97f3..ae2c482475 100644 --- a/lib/chef/provider/cron.rb +++ b/lib/chef/provider/cron.rb @@ -200,15 +200,18 @@ class Chef end def read_crontab - crontab = nil so = shell_out!("crontab -l -u #{new_resource.user}", returns: [0, 1]) return nil if so.exitstatus == 1 so.stdout + rescue Mixlib::ShellOut::ShellCommandFailed => e + raise Chef::Exceptions::Cron, "Error determining state of #{new_resource.name}, error: #{e}" end def write_crontab(crontab) write_exception = false - shell_out!("crontab -u #{new_resource.user} -", input: crontab) + so = shell_out!("crontab -u #{new_resource.user} -", input: crontab) + rescue Mixlib::ShellOut::ShellCommandFailed => e + raise Chef::Exceptions::Cron, "Error updating state of #{new_resource.name}, error: #{e}" end def get_crontab_entry diff --git a/spec/functional/resource/cron_spec.rb b/spec/functional/resource/cron_spec.rb index 156babcffe..1bff8bf874 100644 --- a/spec/functional/resource/cron_spec.rb +++ b/spec/functional/resource/cron_spec.rb @@ -161,7 +161,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do end def cron_create_should_raise_exception - expect { new_resource.run_action(:create) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed) + expect { new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::Cron) cron_should_not_exists(new_resource.name) end |