summaryrefslogtreecommitdiffstats
path: root/lib/puppet/file_bucket
diff options
context:
space:
mode:
authorJacob Helwig <jacob@puppetlabs.com>2011-08-02 10:34:06 -0700
committerJacob Helwig <jacob@puppetlabs.com>2011-08-02 16:33:42 -0700
commitb4cacfd8f95577c514999b4dd6bcb7ad57e37207 (patch)
tree44796bd46351ef3dcb8008d259acbae0628ff080 /lib/puppet/file_bucket
parent207d41f798356d7001f5de971e118e3c33d5f6d1 (diff)
downloadpuppet-b4cacfd8f95577c514999b4dd6bcb7ad57e37207.tar.gz
puppet-b4cacfd8f95577c514999b4dd6bcb7ad57e37207.tar.xz
puppet-b4cacfd8f95577c514999b4dd6bcb7ad57e37207.zip
Clarify logic and error messages when initializing Puppet::FileBucket::File
Rather than stating the logic as 'if !thing', the two checks done when initializing a new Puppet::FileBucket::File are now phrased as 'unless thing', which should lessen the likelihood of overlooking the '!'. We also now provide a reason for the ArgumentError being raised, which should help users of Puppet::FileBucket::File quickly figure out what is the problem when these exceptions are raised. In addition to updating the tests to look for these new error messages, we update the existing tests to specify which type of exception, and what message it should have, when something is raised. Reviewed-by: Nick Lewis <nick@puppetlabs.com>
Diffstat (limited to 'lib/puppet/file_bucket')
-rw-r--r--lib/puppet/file_bucket/file.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/puppet/file_bucket/file.rb b/lib/puppet/file_bucket/file.rb
index 08c0329f1..2a0558fde 100644
--- a/lib/puppet/file_bucket/file.rb
+++ b/lib/puppet/file_bucket/file.rb
@@ -15,11 +15,11 @@ class Puppet::FileBucket::File
attr :bucket_path
def initialize( contents, options = {} )
- raise ArgumentError if !contents.is_a?(String)
- @contents = contents
+ raise ArgumentError.new("contents must be a String, got a #{contents.class}") unless contents.is_a?(String)
+ @contents = contents
@bucket_path = options.delete(:bucket_path)
- raise ArgumentError if options != {}
+ raise ArgumentError.new("Unknown option(s): #{options.keys.join(', ')}") unless options.empty?
end
def checksum_type