diff --git a/py-rattler/docs/activation_error.md b/py-rattler/docs/activation_error.md new file mode 100644 index 000000000..8c5006803 --- /dev/null +++ b/py-rattler/docs/activation_error.md @@ -0,0 +1,3 @@ +# ActivationError + +::: rattler.exceptions.ActivationError diff --git a/py-rattler/docs/cache_dir_error.md b/py-rattler/docs/cache_dir_error.md new file mode 100644 index 000000000..0a661977c --- /dev/null +++ b/py-rattler/docs/cache_dir_error.md @@ -0,0 +1,3 @@ +# CacheDirError + +::: rattler.exceptions.CacheDirError diff --git a/py-rattler/docs/detect_virtual_package_error.md b/py-rattler/docs/detect_virtual_package_error.md new file mode 100644 index 000000000..cc42c0d9e --- /dev/null +++ b/py-rattler/docs/detect_virtual_package_error.md @@ -0,0 +1,4 @@ +# DetectVirtualPackageError + +::: rattler.exceptions.DetectVirtualPackageError + diff --git a/py-rattler/docs/fetch_repo_data_error.md b/py-rattler/docs/fetch_repo_data_error.md new file mode 100644 index 000000000..510d53282 --- /dev/null +++ b/py-rattler/docs/fetch_repo_data_error.md @@ -0,0 +1,4 @@ +# FetchRepoDataError + +::: rattler.exceptions.FetchRepoDataError + diff --git a/py-rattler/docs/invalid_channel_error.md b/py-rattler/docs/invalid_channel_error.md new file mode 100644 index 000000000..18f61747b --- /dev/null +++ b/py-rattler/docs/invalid_channel_error.md @@ -0,0 +1,4 @@ +# InvalidChannelError + +::: rattler.exceptions.InvalidChannelError + diff --git a/py-rattler/docs/invalid_match_spec_error.md b/py-rattler/docs/invalid_match_spec_error.md new file mode 100644 index 000000000..2a7fcf9b1 --- /dev/null +++ b/py-rattler/docs/invalid_match_spec_error.md @@ -0,0 +1,4 @@ +# InvalidMatchSpecError + +::: rattler.exceptions.InvalidMatchSpecError + diff --git a/py-rattler/docs/invalid_package_name_error.md b/py-rattler/docs/invalid_package_name_error.md new file mode 100644 index 000000000..c8560fee1 --- /dev/null +++ b/py-rattler/docs/invalid_package_name_error.md @@ -0,0 +1,4 @@ +# InvalidPackageNameError + +::: rattler.exceptions.InvalidPackageNameError + diff --git a/py-rattler/docs/invalid_url_error.md b/py-rattler/docs/invalid_url_error.md new file mode 100644 index 000000000..6eceb874a --- /dev/null +++ b/py-rattler/docs/invalid_url_error.md @@ -0,0 +1,4 @@ +# InvalidUrlError + +::: rattler.exceptions.InvalidUrlError + diff --git a/py-rattler/docs/invalid_version_error.md b/py-rattler/docs/invalid_version_error.md new file mode 100644 index 000000000..fbf0c8331 --- /dev/null +++ b/py-rattler/docs/invalid_version_error.md @@ -0,0 +1,4 @@ +# InvalidVersionError + +::: rattler.exceptions.InvalidVersionError + diff --git a/py-rattler/docs/io_error.md b/py-rattler/docs/io_error.md new file mode 100644 index 000000000..650b27b1d --- /dev/null +++ b/py-rattler/docs/io_error.md @@ -0,0 +1,4 @@ +# IoError + +::: rattler.exceptions.IoError + diff --git a/py-rattler/docs/link_error.md b/py-rattler/docs/link_error.md new file mode 100644 index 000000000..827a7a7b8 --- /dev/null +++ b/py-rattler/docs/link_error.md @@ -0,0 +1,4 @@ +# LinkError + +::: rattler.exceptions.LinkError + diff --git a/py-rattler/docs/parse_arch_error.md b/py-rattler/docs/parse_arch_error.md new file mode 100644 index 000000000..b0681a1c9 --- /dev/null +++ b/py-rattler/docs/parse_arch_error.md @@ -0,0 +1,4 @@ +# ParseArchError + +::: rattler.exceptions.ParseArchError + diff --git a/py-rattler/docs/parse_platform_error.md b/py-rattler/docs/parse_platform_error.md new file mode 100644 index 000000000..75d6c5e7b --- /dev/null +++ b/py-rattler/docs/parse_platform_error.md @@ -0,0 +1,4 @@ +# ParsePlatformError + +::: rattler.exceptions.ParsePlatformError + diff --git a/py-rattler/docs/solver_error.md b/py-rattler/docs/solver_error.md new file mode 100644 index 000000000..ea0047549 --- /dev/null +++ b/py-rattler/docs/solver_error.md @@ -0,0 +1,3 @@ +# solver_error + +::: rattler.exceptions.SolverError diff --git a/py-rattler/docs/transaction_error.md b/py-rattler/docs/transaction_error.md new file mode 100644 index 000000000..18fe4bb90 --- /dev/null +++ b/py-rattler/docs/transaction_error.md @@ -0,0 +1,4 @@ +# TransactionError + +::: rattler.exceptions.TransactionError + diff --git a/py-rattler/mkdocs.yml b/py-rattler/mkdocs.yml index 845641086..8b2afc592 100644 --- a/py-rattler/mkdocs.yml +++ b/py-rattler/mkdocs.yml @@ -60,6 +60,22 @@ nav: - ActivationVariables: activation_variables.md - Shell: shell.md - PathModificationBehavior: path_modification_behavior.md + - exceptions: + - ActivationError: activation_error.md + - CacheDirError: cache_dir_error.md + - DetectVirtualPackageError: detect_virtual_package_error.md + - FetchRepoDataError: fetch_repo_data_error.md + - InvalidChannelError: invalid_channel_error.md + - InvalidMatchSpecError: invalid_match_spec_error.md + - InvalidPackageNameError: invalid_package_name_error.md + - InvalidUrlError: invalid_url_error.md + - InvalidVersionError: invalid_version_error.md + - IoError: io_error.md + - LinkError: link_error.md + - ParseArchError: parse_arch_error.md + - ParsePlatformError: parse_platform_error.md + - SolverError: solver_error.md + - TransactionError: transaction_error.md plugins: - mkdocstrings: diff --git a/py-rattler/rattler/exceptions.py b/py-rattler/rattler/exceptions.py new file mode 100644 index 000000000..69d9e9a45 --- /dev/null +++ b/py-rattler/rattler/exceptions.py @@ -0,0 +1,85 @@ +try: + from rattler.rattler import ( + InvalidVersionError, + InvalidMatchSpecError, + InvalidPackageNameError, + InvalidUrlError, + InvalidChannelError, + ActivationError, + ParsePlatformError, + ParseArchError, + TransactionError, + LinkError, + IoError, + DetectVirtualPackageError, + CacheDirError, + FetchRepoDataError, + SolverError, + ) +except ImportError: + # They are only redefined for documentation purposes + # when there is no binary yet + + class InvalidVersionError(Exception): # type: ignore[no-redef] + """Error that can occur when parsing a Version""" + + class InvalidMatchSpecError(Exception): # type: ignore[no-redef] + """Error that can occur when parsing a MatchSpec""" + + class InvalidPackageNameError(Exception): # type: ignore[no-redef] + """Error that can occur when parsing a package name""" + + class InvalidUrlError(Exception): # type: ignore[no-redef] + """Error that can occur when parsing a URL""" + + class InvalidChannelError(Exception): # type: ignore[no-redef] + """Error that can occur when parsing a channel.""" + + class ActivationError(Exception): # type: ignore[no-redef] + """Error that can occur when activating a conda environment""" + + class ParsePlatformError(Exception): # type: ignore[no-redef] + """An error that can occur when parsing a platform from a string.""" + + class ParseArchError(Exception): # type: ignore[no-redef] + """An error that can occur when parsing an arch from a string.""" + + class TransactionError(Exception): # type: ignore[no-redef] + """An error that can occur when executing a transaction""" + + class LinkError(Exception): # type: ignore[no-redef] + """An error that can occur when linking a package""" + + class IoError(Exception): # type: ignore[no-redef] + """An error that can occur during io operations""" + + class DetectVirtualPackageError(Exception): # type: ignore[no-redef] + """An error that can occur when trying to detect virtual packages""" + + class CacheDirError(Exception): # type: ignore[no-redef] + """An error that can occur when querying the cache directory""" + + class FetchRepoDataError(Exception): # type: ignore[no-redef] + """An error that can occur when fetching repo data""" + + class SolverError(Exception): # type: ignore[no-redef] + """An error that can occur when trying to solve an environment""" + + +__all__ = [ + "ActivationError", + "CacheDirError", + "DetectVirtualPackageError", + "FetchRepoDataError", + "InvalidChannelError", + "InvalidMatchSpecError", + "InvalidPackageNameError", + "InvalidUrlError", + "InvalidVersionError", + "IoError", + "LinkError", + "ParseArchError", + "ParsePlatformError", + "SolverError", + "TransactionError", +] diff --git a/py-rattler/src/lib.rs b/py-rattler/src/lib.rs index 994f8bd2a..0bb73f7bb 100644 --- a/py-rattler/src/lib.rs +++ b/py-rattler/src/lib.rs @@ -17,9 +17,10 @@ mod virtual_package; use channel::{PyChannel, PyChannelConfig}; use error::{ - ActivationException, InvalidChannelException, InvalidMatchSpecException, - InvalidPackageNameException, InvalidUrlException, InvalidVersionException, ParseArchException, - ParsePlatformException, PyRattlerError, + ActivationException, CacheDirException, DetectVirtualPackageException, FetchRepoDataException, + InvalidChannelException, InvalidMatchSpecException, InvalidPackageNameException, + InvalidUrlException, InvalidVersionException, IoException, LinkException, ParseArchException, + ParsePlatformException, PyRattlerError, SolverException, TransactionException, }; use generic_virtual_package::PyGenericVirtualPackage; use match_spec::PyMatchSpec; @@ -116,6 +117,23 @@ fn rattler(py: Python, m: &PyModule) -> PyResult<()> { .unwrap(); m.add("ParseArchError", py.get_type::()) .unwrap(); - + m.add("SolverError", py.get_type::()) + .unwrap(); + m.add("TransactionError", py.get_type::()) + .unwrap(); + m.add("LinkError", py.get_type::()).unwrap(); + m.add("IoError", py.get_type::()).unwrap(); + m.add( + "DetectVirtualPackageError", + py.get_type::(), + ) + .unwrap(); + m.add("CacheDirError", py.get_type::()) + .unwrap(); + m.add( + "FetchRepoDataError", + py.get_type::(), + ) + .unwrap(); Ok(()) }