Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raising an error when response returns any status code but 200. #11

Merged
merged 1 commit into from
Oct 16, 2014

Conversation

menegazzo
Copy link
Owner

This fixes #10

@menegazzo menegazzo added this to the 0.3.1 milestone Oct 15, 2014
@menegazzo menegazzo added the bug label Oct 15, 2014
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 4173df4 on fb-10-raising-errors into 75fe7f4 on master.

@@ -223,7 +226,9 @@ def test_jobs(self, python_version, repo_slug):
assert build == job.build

job.build_id = -1
assert job.build is None
with pytest.raises(TravisError) as exception_info:
job.build
Copy link
Contributor

Choose a reason for hiding this comment

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

While I really like TravisPy.github_auth raising an error, raising an exception for job.build and job.log feels weird for me. Seems that it may lead to code like this:

try:
    build = job.build
except TravisError:
    # not sure what the user can do in this case
else:
    # job has a build    

Can you give an example in which real-life situation a job wouldn't have a associated build or log? I haven't used the travis api extensively, so some enlightment here is appreciated! 😄

Copy link
Owner Author

Choose a reason for hiding this comment

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

Both properties build and log uses related *_id to actually load/create objects. This is basically to test how _load_lazy_information will behave when facing invalid IDs. I am just foreseeing this kind of problem, it never happened so far. Maybe it is a gold plate that is worth to remove.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, so this is an exceptional case and not really part a common usage scenario.

Then I guess this is just fine the way it is, thanks!

@nicoddemus
Copy link
Contributor

Looks good to me, feel free to merge!

menegazzo added a commit that referenced this pull request Oct 16, 2014
Raising an error when response returns any status code but 200.
@menegazzo menegazzo merged commit 395caf9 into master Oct 16, 2014
@menegazzo menegazzo deleted the fb-10-raising-errors branch October 16, 2014 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Raise errors instead of ignoring them
3 participants