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

moved exceptions conans->conan #17126

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conan/api/conan_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from conan.api.subapi.upload import UploadAPI
from conans.client.migrations import ClientMigrator
from conans.client.userio import init_colorama
from conans.errors import ConanException
from conan.errors import ConanException
from conans.model.version import Version
from conan.internal.paths import get_conan_user_home
from conans.model.version_range import validate_conan_version
Expand Down
3 changes: 2 additions & 1 deletion conan/api/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

from conans.client.graph.graph import RECIPE_EDITABLE, RECIPE_CONSUMER, RECIPE_PLATFORM, \
RECIPE_VIRTUAL, BINARY_SKIP, BINARY_MISSING, BINARY_INVALID
from conans.errors import ConanException, NotFoundException
from conan.internal.errors import NotFoundException
from conan.errors import ConanException
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference
from conans.util.files import load
Expand Down
2 changes: 1 addition & 1 deletion conan/api/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from colorama import Fore, Style

from conans.client.userio import color_enabled
from conans.errors import ConanException
from conan.errors import ConanException

LEVEL_QUIET = 80 # -q
LEVEL_ERROR = 70 # Errors
Expand Down
2 changes: 1 addition & 1 deletion conan/api/subapi/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from conan.internal.conan_app import ConanApp
from conan.internal.cache.integrity_check import IntegrityChecker
from conans.client.downloaders.download_cache import DownloadCache
from conans.errors import ConanException
from conan.errors import ConanException
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference
from conans.util.dates import revision_timestamp_now
Expand Down
2 changes: 1 addition & 1 deletion conan/api/subapi/command.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from conans.errors import ConanException
from conan.errors import ConanException


class CommandAPI:
Expand Down
2 changes: 1 addition & 1 deletion conan/api/subapi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from conans.client.graph.graph import CONTEXT_HOST, RECIPE_VIRTUAL, Node
from conans.client.graph.graph_builder import DepsGraphBuilder
from conans.client.graph.profile_node_definer import consumer_definer
from conans.errors import ConanException
from conan.errors import ConanException
from conans.model.conf import ConfDefinition, BUILT_IN_CONFS
from conans.model.pkg_type import PackageType
from conans.model.recipe_ref import RecipeReference
Expand Down
2 changes: 1 addition & 1 deletion conan/api/subapi/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from conan.api.model import Remote, PackagesList
from conan.api.output import ConanOutput
from conan.internal.conan_app import ConanApp
from conans.errors import ConanException
from conan.errors import ConanException
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference

Expand Down
2 changes: 1 addition & 1 deletion conan/api/subapi/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from conans.client.graph.graph_binaries import GraphBinariesAnalyzer
from conans.client.graph.graph_builder import DepsGraphBuilder
from conans.client.graph.profile_node_definer import initialize_conanfile_profile, consumer_definer
from conans.errors import ConanException
from conan.errors import ConanException
from conans.model.recipe_ref import RecipeReference


Expand Down
2 changes: 1 addition & 1 deletion conan/api/subapi/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from conans.client.graph.install_graph import InstallGraph
from conans.client.installer import BinaryInstaller
from conans.errors import ConanInvalidConfiguration
from conan.errors import ConanInvalidConfiguration


class InstallAPI:
Expand Down
3 changes: 2 additions & 1 deletion conan/api/subapi/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from conan.internal.api.list.query_parse import filter_package_configs
from conan.internal.conan_app import ConanApp
from conan.internal.paths import CONANINFO
from conans.errors import ConanException, NotFoundException
from conan.internal.errors import NotFoundException
from conan.errors import ConanException
from conans.model.info import load_binary_info
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference, ref_matches
Expand Down
3 changes: 2 additions & 1 deletion conan/api/subapi/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from conans.client.graph.graph import CONTEXT_HOST
from conans.client.graph.profile_node_definer import initialize_conanfile_profile
from conans.client.source import run_source_method
from conans.errors import ConanException, conanfile_exception_formatter
from conan.internal.errors import conanfile_exception_formatter
from conan.errors import ConanException
from conans.model.recipe_ref import RecipeReference
from conans.util.files import chdir

Expand Down
2 changes: 1 addition & 1 deletion conan/api/subapi/lockfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from conan.api.output import ConanOutput
from conan.cli import make_abs_path
from conans.client.graph.graph import Overrides
from conans.errors import ConanException
from conan.errors import ConanException
from conans.model.graph_lock import Lockfile, LOCKFILE


Expand Down
2 changes: 1 addition & 1 deletion conan/api/subapi/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from jinja2 import Template, StrictUndefined

from conans.errors import ConanException
from conan.errors import ConanException
from conans.util.files import load
from conans import __version__

Expand Down
3 changes: 2 additions & 1 deletion conan/api/subapi/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

from conans.client.loader import load_python_file
from conan.internal.api.profile.profile_loader import ProfileLoader
from conans.errors import ConanException, scoped_traceback
from conan.internal.errors import scoped_traceback
from conan.errors import ConanException
from conans.model.profile import Profile

DEFAULT_PROFILE_NAME = "default"
Expand Down
2 changes: 1 addition & 1 deletion conan/api/subapi/remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from conans.client.rest_client_local_recipe_index import add_local_recipes_index_remote, \
remove_local_recipes_index_remote
from conan.internal.api.remotes.localdb import LocalDB
from conans.errors import ConanException
from conan.errors import ConanException
from conans.util.files import save, load

CONAN_CENTER_REMOTE_NAME = "conancenter"
Expand Down
3 changes: 2 additions & 1 deletion conan/api/subapi/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
gather_metadata
from conans.client.pkg_sign import PkgSignaturesPlugin
from conans.client.rest.file_uploader import FileUploader
from conans.errors import ConanException, AuthenticationException, ForbiddenException
from conan.internal.errors import AuthenticationException, ForbiddenException
from conan.errors import ConanException


class UploadAPI:
Expand Down
2 changes: 1 addition & 1 deletion conan/cli/commands/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from conan.cli import make_abs_path
from conan.cli.command import conan_command, OnceArgument
from conan.cli.commands.list import print_list_text, print_list_json
from conans.errors import ConanException
from conan.errors import ConanException


@conan_command(group="Creator", formatters={"text": print_list_text,
Expand Down
2 changes: 1 addition & 1 deletion conan/cli/commands/export_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from conan.cli.commands.create import _get_test_conanfile_path
from conan.cli.formatters.graph import format_graph_json
from conan.cli.printers.graph import print_graph_basic
from conans.errors import ConanException
from conan.errors import ConanException


@conan_command(group="Creator", formatters={"json": format_graph_json})
Expand Down
2 changes: 1 addition & 1 deletion conan/cli/commands/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from conan.internal.deploy import do_deploys
from conans.client.graph.graph import BINARY_MISSING
from conans.client.graph.install_graph import InstallGraph
from conans.errors import NotFoundException
from conan.internal.errors import NotFoundException
from conans.model.recipe_ref import ref_matches, RecipeReference


Expand Down
2 changes: 1 addition & 1 deletion conan/cli/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from conan.cli import make_abs_path
from conan.cli.command import conan_command, OnceArgument
from conan.cli.formatters.list import list_packages_html
from conans.errors import ConanException
from conan.errors import ConanException
from conans.util.dates import timestamp_to_str


Expand Down
2 changes: 1 addition & 1 deletion conan/cli/commands/pkglist.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from conan.cli.command import conan_command, conan_subcommand
from conan.cli.commands.list import print_list_text, print_list_json
from conan.cli.formatters.list import list_packages_html
from conans.errors import NotFoundException
from conan.internal.errors import NotFoundException


@conan_command(group="Consumer")
Expand Down
2 changes: 1 addition & 1 deletion conan/cli/commands/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from conan.cli.command import conan_command, OnceArgument
from conan.cli.commands.list import print_list_json, print_serial
from conans.client.userio import UserInput
from conans.errors import ConanException
from conan.errors import ConanException


def summary_remove_list(results):
Expand Down
25 changes: 22 additions & 3 deletions conan/errors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
from conans.errors import ConanException
from conans.errors import ConanInvalidConfiguration
from conans.errors import ConanMigrationError
class ConanException(Exception):
""" Generic conan exception """
def __init__(self, msg=None, remote=None):
self.remote = remote
super().__init__(msg)

def __str__(self):
msg = super().__str__()
if self.remote:
return f"{msg}. [Remote: {self.remote.name}]"
return msg


class ConanInvalidConfiguration(ConanException):
"""
This binary, for the requested configuration and package-id cannot be built
"""
pass


class ConanMigrationError(ConanException):
pass
2 changes: 1 addition & 1 deletion conan/internal/api/config/config_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from conan.api.output import ConanOutput
from conans.client.downloaders.file_downloader import FileDownloader
from conans.errors import ConanException
from conan.errors import ConanException
from conans.util.files import mkdir, rmdir, remove, unzip, chdir
from conans.util.runners import detect_runner

Expand Down
2 changes: 1 addition & 1 deletion conan/internal/api/detect/detect_vs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from shutil import which

from conan.tools.build import cmd_args_to_string
from conans.errors import ConanException
from conan.errors import ConanException


def vs_installation_path(version):
Expand Down
3 changes: 2 additions & 1 deletion conan/internal/api/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from conan.tools.files import copy
from conan.api.output import ConanOutput
from conan.tools.scm import Git
from conans.errors import ConanException, conanfile_exception_formatter
from conan.internal.errors import conanfile_exception_formatter
from conan.errors import ConanException
from conans.model.manifest import FileTreeManifest
from conans.model.recipe_ref import RecipeReference
from conan.internal.paths import DATA_YML
Expand Down
3 changes: 2 additions & 1 deletion conan/internal/api/install/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

from conan.internal.cache.home_paths import HomePaths
from conans.client.subsystems import deduce_subsystem, subsystem_path
from conans.errors import ConanException, conanfile_exception_formatter
from conan.internal.errors import conanfile_exception_formatter
from conan.errors import ConanException
from conans.util.files import save, mkdir, chdir

_generators = {"CMakeToolchain": "conan.tools.cmake",
Expand Down
2 changes: 1 addition & 1 deletion conan/internal/api/profile/profile_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from conan.internal.api.detect import detect_api
from conan.internal.cache.home_paths import HomePaths
from conan.tools.env.environment import ProfileEnvironment
from conans.errors import ConanException
from conan.errors import ConanException
from conans.model.conf import ConfDefinition, CORE_CONF_PATTERN
from conans.model.options import Options
from conans.model.profile import Profile
Expand Down
3 changes: 2 additions & 1 deletion conan/internal/api/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from conan.internal.conan_app import ConanApp
from conan.api.output import ConanOutput
from conans.client.source import retrieve_exports_sources
from conans.errors import ConanException, NotFoundException
from conan.internal.errors import NotFoundException
from conan.errors import ConanException
from conan.internal.paths import (CONAN_MANIFEST, CONANFILE, EXPORT_SOURCES_TGZ_NAME,
EXPORT_TGZ_NAME, PACKAGE_TGZ_NAME, CONANINFO)
from conans.util.files import (clean_dirty, is_dirty, gather_files,
Expand Down
3 changes: 2 additions & 1 deletion conan/internal/cache/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
# TODO: Random folders are no longer accessible, how to get rid of them asap?
# TODO: We need the workflow to remove existing references.
from conan.internal.cache.db.cache_database import CacheDatabase
from conans.errors import ConanReferenceAlreadyExistsInDB, ConanException
from conan.internal.errors import ConanReferenceAlreadyExistsInDB
from conan.errors import ConanException
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference
from conans.util.dates import revision_timestamp_now
Expand Down
2 changes: 1 addition & 1 deletion conan/internal/cache/db/packages_table.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sqlite3

from conan.internal.cache.db.table import BaseDbTable
from conans.errors import ConanReferenceDoesNotExistInDB, ConanReferenceAlreadyExistsInDB
from conan.internal.errors import ConanReferenceDoesNotExistInDB, ConanReferenceAlreadyExistsInDB
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference
from conans.util.dates import timestamp_now
Expand Down
2 changes: 1 addition & 1 deletion conan/internal/cache/db/recipes_table.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sqlite3

from conan.internal.cache.db.table import BaseDbTable
from conans.errors import ConanReferenceDoesNotExistInDB, ConanReferenceAlreadyExistsInDB
from conan.internal.errors import ConanReferenceDoesNotExistInDB, ConanReferenceAlreadyExistsInDB
from conans.model.recipe_ref import RecipeReference
from conans.util.dates import timestamp_now

Expand Down
2 changes: 1 addition & 1 deletion conan/internal/cache/integrity_check.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

from conan.api.output import ConanOutput
from conans.errors import ConanException
from conan.errors import ConanException
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference

Expand Down
3 changes: 2 additions & 1 deletion conan/internal/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from conan.internal.cache.home_paths import HomePaths
from conan.api.output import ConanOutput
from conans.client.loader import load_python_file
from conans.errors import ConanException, conanfile_exception_formatter
from conan.internal.errors import conanfile_exception_formatter
from conan.errors import ConanException
from conans.util.files import rmdir, mkdir


Expand Down
36 changes: 2 additions & 34 deletions conans/errors.py → conan/internal/errors.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
"""
Exceptions raised and handled in Conan
These exceptions are mapped between server (as an HTTP response) and client
through the REST API. When an error happens in server its translated to an HTTP
error code that its sent to client. Client reads the server code and raise the
matching exception.

see return_plugin.py
"""
import traceback
from contextlib import contextmanager

from conan.errors import ConanException, ConanInvalidConfiguration


@contextmanager
def conanfile_remove_attr(conanfile, names, method):
Expand Down Expand Up @@ -88,19 +81,6 @@ def scoped_traceback(header_msg, exception, scope):
return ret


class ConanException(Exception):
""" Generic conan exception """
def __init__(self, msg=None, remote=None):
self.remote = remote
super().__init__(msg)

def __str__(self):
msg = super().__str__()
if self.remote:
return f"{msg}. [Remote: {self.remote.name}]"
return msg


class ConanReferenceDoesNotExistInDB(ConanException):
""" Reference does not exist in cache db """
pass
Expand All @@ -115,18 +95,6 @@ class ConanConnectionError(ConanException):
pass


class ConanInvalidConfiguration(ConanException):
"""
This binary, for the requested configuration and package-id cannot be built
"""
pass


class ConanMigrationError(ConanException):
pass


# Remote exceptions #
class InternalErrorException(ConanException):
"""
Generic 500 error
Expand Down
2 changes: 1 addition & 1 deletion conan/internal/internal_tools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from conans.errors import ConanException
from conan.errors import ConanException

universal_arch_separator = '|'

Expand Down
Loading