Skip to content

Commit

Permalink
adding the response code to the error
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaltom committed May 9, 2014
1 parent 641288b commit 38c2030
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/suse/connect/cli.rb
Expand Up @@ -24,7 +24,7 @@ def execute! # rubocop:disable MethodLength
Client.new(@options).register!

rescue ApiError => e
log.error "Error: SCC returned '#{e.message}'"
log.error "Error: SCC returned '#{e.message}' (#{e.code})"
exit 1
rescue Errno::ECONNREFUSED
log.error 'Error: Connection refused by server'
Expand Down
6 changes: 1 addition & 5 deletions lib/suse/connect/errors.rb
Expand Up @@ -22,12 +22,8 @@ def code
@response.code
end

def body
@response.body
end

def message
body['localized_error']
@response.body['localized_error']
end

end
Expand Down
2 changes: 1 addition & 1 deletion spec/connect/cli_spec.rb
Expand Up @@ -23,7 +23,7 @@
describe '#execute!' do

it 'should produce log output if ApiError encountered' do
string_logger.should_receive(:error).with("Error: SCC returned 'test'")
string_logger.should_receive(:error).with("Error: SCC returned 'test' (222)")
response = Net::HTTPResponse.new('1.1', 222, 'Test')
expect(response).to receive(:body).and_return('localized_error' => 'test')
Client.any_instance.stub(:register!).and_raise ApiError.new(response)
Expand Down

0 comments on commit 38c2030

Please sign in to comment.