Skip to content

Comments

Improve error message#69

Open
vsanta wants to merge 5 commits intoYelp:developfrom
vsanta:improve_error_message
Open

Improve error message#69
vsanta wants to merge 5 commits intoYelp:developfrom
vsanta:improve_error_message

Conversation

@vsanta
Copy link

@vsanta vsanta commented Dec 11, 2016

Including description of the error in the exception message. This is only included if provided back form the API.

I also standardized the error_spec to have all examples use raise_error.

Copy link

@ajm188 ajm188 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests can still be improved a bit. Other than that just minor nit


it 'should expose the field parameter' do
begin
expect{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space here expect {

# verifies that we can get access to the specific field that was invalid
expect(e.field).to eq('oauth_token')
end
}.to raise_error { |error|
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect { ... }.to raise_error(Yelp::Error::InvalidParameter, 'One or more ...')

documentation

expect {
Yelp::Error.check_for_error(bad_response)
}.to raise_error { |error|
error.message.should eq('One or more parameters are invalid in request: limit. Description: Limit maximum is 20')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

@vsanta
Copy link
Author

vsanta commented Dec 11, 2016

@ajm188 statistic preferences are hard to guess (block vs. non-block) :/

The non-block style will not allow the validation of field. This is something that was covered before and I didn't want to remove it.

Otherwise, it would make sense to have it 'should raise an invalid response error' and 'should expose the field parameter'merged with a single assertion

`
raise_error(Yelp::Error::InvalidParameter, 'One or more parameters are invalid in request: oauth_token')

Right?In this case it meanfield` is assigned but never tested for.

* Prefer param vs block
* Remove assertion for field
@ajm188
Copy link

ajm188 commented Dec 12, 2016

statistic preferences are hard to guess (block vs. non-block) :/

I totally feel you on this, but I still want that space in there! :)

The non-block style will not allow the validation of field. This is something that was covered before and I didn't want to remove it.

We're still implicitly testing it, because the field name appears in the error message. But I will defer to @tomelm and @mittonk here, as they have more historical context than I do.

error.message.should eq('One or more parameters are invalid in request: oauth_token')
error.field.should eq('oauth_token')
}
}.to raise_error ('One or more parameters are invalid in request: oauth_token')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still missing: expect { }.to raise_error(ErrorClass, error_message)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants