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

Handling error when reference not found using conan download #5399

Merged
merged 19 commits into from
Jun 25, 2019

Conversation

czoido
Copy link
Contributor

@czoido czoido commented Jun 25, 2019

Changelog: Fix: Handling error when reference not found using conan download
Docs: Omit

Fixes: #5397

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.

@czoido czoido requested a review from jgsogo June 25, 2019 15:08
@@ -74,6 +74,13 @@ def wrapper(*args, **kwargs):
with tools.environment_append(api._cache.config.env_vars):
# Patch the globals in tools
return f(*args, **kwargs)
except NotFoundException as exc:
Copy link
Member

Choose a reason for hiding this comment

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

Hi @czoido

I don't think this should be handled here, but much sooner. Here it is too late, and there are other things that could cause a NotFoundException (e.g. trying to download a .zip for the conan config install).

It is the exception itself who should encode a better error message as close to the raise as possible, by the one that has the context (remote_name, ref, or whatever makes sense)

@czoido czoido requested a review from memsharded June 25, 2019 16:17
Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

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

Much better. Please also add a test, or an extra check to an existing test, and it could be merged. Thanks!

try:
ref = remote_manager.get_recipe(ref, remote)
except NotFoundException as exc:
if exc.args and "404" in exc.args[0]:
Copy link
Member

Choose a reason for hiding this comment

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

You can skip the check of 404, you already got that exception. It is ok to re-raise it with a new message.

@memsharded
Copy link
Member

Check the broken test: https://conan-ci.jfrog.info/blue/organizations/jenkins/ConanTestSuite/detail/PR-5399/3/pipeline

Also, consider adding a new test or a new check in existing test for the download command behavior.

@memsharded memsharded added this to the 1.17 milestone Jun 25, 2019
@memsharded memsharded merged commit b6840cc into conan-io:develop Jun 25, 2019
@memsharded memsharded self-assigned this Jun 25, 2019
@memsharded
Copy link
Member

Great, thanks!

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.

Proper error handling with conan download
2 participants