Skip to content

Commit d05e894

Browse files
committed
Add an error #message method so the details will be displayed in subsequent logging.
1 parent 89c44d8 commit d05e894

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/omniauth/strategies/oauth2.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ def initialize(error, error_reason=nil, error_uri=nil)
109109
self.error_reason = error_reason
110110
self.error_uri = error_uri
111111
end
112+
113+
def message
114+
[self.error, self.error_reason, self.error_uri].compact.join(' | ')
115+
end
112116
end
113117
end
114118
end

spec/omniauth/strategies/oauth2_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,20 @@ def app; lambda{|env| [200, {}, ["Hello."]]} end
6161
end
6262
end
6363
end
64+
65+
describe OmniAuth::Strategies::OAuth2::CallbackError do
66+
let(:error){ Class.new(OmniAuth::Strategies::OAuth2::CallbackError) }
67+
describe '#message' do
68+
subject { error }
69+
it "should include all of the attributes" do
70+
instance = subject.new('error', 'description', 'uri')
71+
instance.message.should =~ /error/
72+
instance.message.should =~ /description/
73+
instance.message.should =~ /uri/
74+
end
75+
it "should include all of the attributes" do
76+
instance = subject.new(nil, :symbol)
77+
instance.message.should == 'symbol'
78+
end
79+
end
80+
end

0 commit comments

Comments
 (0)