From 596f3ba0a00b90d6a47ef5860b371f08fc8a72bd Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Wed, 16 Jul 2014 21:11:48 -0500 Subject: Raise ArgumentError when a symbol can't be mapped to a version The fact that this is implemented as a hash lookup is an implementation detail, so don't let the KeyError bubble up. --- Library/Homebrew/os/mac/version.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/os/mac/version.rb') diff --git a/Library/Homebrew/os/mac/version.rb b/Library/Homebrew/os/mac/version.rb index ed05ac553..06901b642 100644 --- a/Library/Homebrew/os/mac/version.rb +++ b/Library/Homebrew/os/mac/version.rb @@ -14,7 +14,10 @@ module OS } def self.from_symbol(sym) - new(SYMBOLS.fetch(sym)) + str = SYMBOLS.fetch(sym) do + raise ArgumentError, "unknown version #{sym.inspect}" + end + new(str) end def initialize(*args) -- cgit v1.2.3