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

[bug] Some exceptions that are returned by API functions are internal #17492

Open
fredizzimo opened this issue Dec 17, 2024 · 2 comments
Open

Comments

@fredizzimo
Copy link
Contributor

fredizzimo commented Dec 17, 2024

Describe the bug

Some exceptions, like NotFoundException is in the conan.internal.errors namespace, however this is a public exception that can be returned by API functions like self.api.local.inspect(), so it should probably be public.

I know that the local API is undocumented at the moment, but we use it for inspect and editable package management, so it should probably not be.

This happens with at least 2.9.3 and 2.10.2

How to reproduce it

No response

@memsharded
Copy link
Member

Hi @fredizzimo

Thanks for your feedback.

At the moment, the public exceptions that users can use in code are those documented and in the public namespace. It is not a problem that Conan is raising a NotFoundException, this should inherit from ConanException so the correct approach so far is to try: ... except ConanException:.

If there is some use case that would support creating more public exceptions, please let us know the details of such a use case. If not, we prefer to keep the number of exceptions raised by Conan and managed by users to a minimum.

@fredizzimo
Copy link
Contributor Author

The use case is/was the following

  1. The workspace we are building contains an unknown amount of conanfiles, with unknown dependencies, including python requirements
  2. We don't want to construct the graph for all operations, nor export everything to the cache, so inspect is used to get basic properties
  3. This fails with NotFoundException in the case where a python requires is not available at that time
  4. So we do something like this (pseudocode)
while packages:
    package = packages.pop()
   try:
       api.local.inspect(package)
       # Export it to cache if it's a python requires package
  except NotFoundException:
      # Retry later (the python requires package will have been processed when it's retried
      packages.append(package)
 # Other errors are complete failures

I realize now that we don't really need this whole complex system anymore, since we only have one python requires package, which we export before everything else. When it was made, I think we had some code generation, so it was not possible to do that.

So, strictly the exception is not needed for us anymore. However, I still think that it's a useful one, since it provides more information than the other reasons of failure.

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

No branches or pull requests

2 participants