Skip to content

Commit d4abaec

Browse files
committed
make error also work without an response
1 parent 8b7b218 commit d4abaec

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/zendesk_api/error.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ class ClientError < Faraday::Error::ClientError
55
attr_reader :wrapped_exception
66

77
def to_s
8-
"#{super} -- #{response.method} #{response.url}"
8+
if response
9+
"#{super} -- #{response.method} #{response.url}"
10+
else
11+
super
12+
end
913
end
1014
end
1115

spec/core/error_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require 'core/spec_helper'
2+
3+
describe ZendeskAPI::Error do
4+
describe ZendeskAPI::Error::ClientError do
5+
it "works without a response" do
6+
expect(ZendeskAPI::Error::ClientError.new("foo").message).to eq "foo"
7+
end
8+
end
9+
end

0 commit comments

Comments
 (0)