diff --git a/lib/sshkit/configuration.rb b/lib/sshkit/configuration.rb
index <HASH>..<HASH> 100644
--- a/lib/sshkit/configuration.rb
+++ b/lib/sshkit/configuration.rb
@@ -53,9 +53,16 @@ module SSHKit
     end
 
     def formatter(format)
-      SSHKit::Formatter.constants.each do |const|
-        return SSHKit::Formatter.const_get(const).new($stdout) if const.downcase.eql?(format.downcase)
+      formatter_class(format).new($stdout)
+    end
+
+    def formatter_class(symbol)
+      name = symbol.to_s.downcase
+      found = SSHKit::Formatter.constants.find do |const|
+        const.to_s.downcase == name
       end
+      fail NameError, 'Unrecognized SSHKit::Formatter "#{symbol}"' if found.nil?
+      SSHKit::Formatter.const_get(found)
     end
 
   end
diff --git a/test/unit/test_configuration.rb b/test/unit/test_configuration.rb
index <HASH>..<HASH> 100644
--- a/test/unit/test_configuration.rb
+++ b/test/unit/test_configuration.rb
@@ -78,6 +78,11 @@ module SSHKit
       end
     end
 
+    def test_prohibits_unknown_formatter_type_with_exception
+      assert_raises(NameError) do
+        SSHKit.config.format = :doesnotexist
+      end
+    end
   end
 
 end
Raise NameError if a bad formatter name is given

This makes the error more explicit and helpful. Previously, setting
`output.format = :bad_value` would not raise immediately, but would fail later
with a confusing error once a logging operation is attempted.