-
Notifications
You must be signed in to change notification settings - Fork 989
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
Conversation
a reference that is not in the remote
conans/client/conan_api.py
Outdated
@@ -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: |
There was a problem hiding this comment.
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)
There was a problem hiding this 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!
conans/client/cmd/download.py
Outdated
try: | ||
ref = remote_manager.get_recipe(ref, remote) | ||
except NotFoundException as exc: | ||
if exc.args and "404" in exc.args[0]: |
There was a problem hiding this comment.
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.
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 |
Great, thanks! |
Changelog: Fix: Handling error when reference not found using conan download
Docs: Omit
Fixes: #5397
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.