Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds better error for missing provider. Closes #536

  • Loading branch information...
commit 4af02425f87afd773b7bb60ff3cb0e222cf7f372 1 parent c98b6e0
@mbleigh mbleigh authored
Showing with 13 additions and 1 deletion.
  1. +5 −1 lib/omniauth/builder.rb
  2. +8 −0 spec/omniauth/builder_spec.rb
View
6 lib/omniauth/builder.rb
@@ -19,7 +19,11 @@ def provider(klass, *args, &block)
if klass.is_a?(Class)
middleware = klass
else
- middleware = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(klass.to_s)}")
+ begin
+ middleware = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(klass.to_s)}")
+ rescue NameError
+ raise LoadError, "Could not find matching strategy for #{klass.inspect}. You may need to install an additional gem (such as omniauth-#{klass})."
+ end
end
use middleware, *args, &block
View
8 spec/omniauth/builder_spec.rb
@@ -16,5 +16,13 @@ class ::ExampleClass; end
provider ::ExampleClass
end }.should_not raise_error
end
+
+ it "should raise a helpful LoadError messgae if it can't find the class" do
+ expect {
+ OmniAuth::Builder.new(nil) do
+ provider :lorax
+ end
+ }.to raise_error(LoadError, "Could not find matching strategy for :lorax. You may need to install an additional gem (such as omniauth-lorax).")
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.