Permalink
Browse files

Ensure there's http code and the body in the exception message

  • Loading branch information...
1 parent 4c419df commit 7b3ad0f6f3747925738f461665d5163a6dafff86 @libc committed Mar 22, 2013
Showing with 12 additions and 1 deletion.
  1. +1 −1 lib/viadeo/helpers/request.rb
  2. +11 −0 spec/query_spec.rb
@@ -74,7 +74,7 @@ def request(method, path, query, data, options)
curl.perform
end
- raise error, "An error, has occured: #{error.inspect}" if error
+ raise error, "An error, has occured: http code: #{error.status}, response body: #{error.data.inspect}" if error
parse_response c
end
View
@@ -20,6 +20,17 @@
expect { client.get('/_raise_http_409') }.to raise_error(Viadeo::Errors::ConflictError)
end
+ it 'includes body and error code in the error message' do
+ e = nil # hoist the error
+ begin
+ client.get '/_raise_http_404', unique_param: 'very unique param'
+ rescue Viadeo::Errors::NotFoundError => e
+ end
+
+ expect(e.message).to include('404')
+ expect(e.message).to include('very unique param')
+ end
+
it 'sends queries' do
obj = client.get('/test', param1: 'test')
expect(obj.body.params.param1).to eq('test')

0 comments on commit 7b3ad0f

Please sign in to comment.