aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/software_spec.rb
diff options
context:
space:
mode:
authorAndrew Janke2016-04-20 02:17:28 -0400
committerAndrew Janke2016-04-21 15:21:44 -0400
commit094f6f47ddcb3cabc30ed935a4be4cf855c94e73 (patch)
treea9f0ac692f60796264b6282651c76ddffe7b7a38 /Library/Homebrew/software_spec.rb
parenta3b70d38a72400451594f7c11853ef2b379a3bca (diff)
downloadbrew-094f6f47ddcb3cabc30ed935a4be4cf855c94e73.tar.bz2
Formula: include bad value in invalid-option error message
Makes identifying which line in a formula has the bad use of 'option' easier. Closes #120. Signed-off-by: Andrew Janke <andrew@apjanke.net>
Diffstat (limited to 'Library/Homebrew/software_spec.rb')
-rw-r--r--Library/Homebrew/software_spec.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb
index 0720fab3d..6477dfd56 100644
--- a/Library/Homebrew/software_spec.rb
+++ b/Library/Homebrew/software_spec.rb
@@ -122,9 +122,12 @@ class SoftwareSpec
puts "Symbols are reserved for future use, please pass a string instead"
name = name.to_s
end
+ unless String === name
+ raise ArgumentError, "option name must be string or symbol; got a #{name.class}: #{name}"
+ end
raise ArgumentError, "option name is required" if name.empty?
- raise ArgumentError, "option name must be longer than one character" unless name.length > 1
- raise ArgumentError, "option name must not start with dashes" if name.start_with?("-")
+ raise ArgumentError, "option name must be longer than one character: #{name}" unless name.length > 1
+ raise ArgumentError, "option name must not start with dashes: #{name}" if name.start_with?("-")
Option.new(name, description)
end
options << opt