summaryrefslogtreecommitdiff
path: root/lib/chef/resource/cron.rb
diff options
context:
space:
mode:
authorRyota Arai <ryota.arai@gmail.com>2013-12-19 23:06:47 +0900
committerBryan McLellan <btm@getchef.com>2014-03-20 13:06:29 -0700
commit7404a1c96c7a29677be2aa0b1fb5abdb8d619373 (patch)
treeb515d65b99e0899cf0c0a8575e71182b872b12d9 /lib/chef/resource/cron.rb
parentaef824f3f6e6300547f96436aab02cfe799c3e12 (diff)
downloadchef-7404a1c96c7a29677be2aa0b1fb5abdb8d619373.tar.gz
Show a short message for invalid value for weekday.
Diffstat (limited to 'lib/chef/resource/cron.rb')
-rw-r--r--lib/chef/resource/cron.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/chef/resource/cron.rb b/lib/chef/resource/cron.rb
index 72f86bc974..0a29afd276 100644
--- a/lib/chef/resource/cron.rb
+++ b/lib/chef/resource/cron.rb
@@ -121,8 +121,12 @@ class Chef
converted_arg = arg
end
begin
- if !arg.is_a?(Symbol) && integerize(arg) > 7
- raise RangeError
+ error_message = "You provided '#{arg}' as a weekday, acceptable values are "
+ error_message << Provider::Cron::WEEKDAY_SYMBOLS.map {|sym| ":#{sym.to_s}"}.join(', ')
+ error_message << " and a string in crontab format"
+ if (arg.is_a?(Symbol) && !Provider::Cron::WEEKDAY_SYMBOLS.include?(arg)) ||
+ (!arg.is_a?(Symbol) && integerize(arg) > 7)
+ raise RangeError, error_message
end
rescue ArgumentError
end