milieux.errors
1from pathlib import Path 2from typing import Union 3 4from milieux.utils import distro_sty, env_sty 5 6 7class MilieuxError(ValueError): 8 """Custom class for errors meant to be handled gracefully.""" 9 10class UserInputError(MilieuxError): 11 """Error for invalid user input.""" 12 13class ConfigNotFoundError(MilieuxError): 14 """Error for when the user's config file cannot be found.""" 15 16class DistroError(MilieuxError): 17 """Error related to a distro.""" 18 19class DistroExistsError(DistroError): 20 """Error for when a distro already exists.""" 21 22class NoSuchDistroError(DistroError): 23 """Error for when a distribution does not exist.""" 24 def __init__(self, distro_name: str) -> None: 25 self.distro_name = distro_name 26 super().__init__(f'No distro named {distro_sty(distro_name)}') 27 28class InvalidDistroError(DistroError): 29 """Error for when a distro is invalid.""" 30 31class EnvError(MilieuxError): 32 """Error related to an environment.""" 33 34class EnvironmentExistsError(EnvError): 35 """Error for when an environment already exists.""" 36 37class NoSuchEnvironmentError(EnvError): 38 """Error for when an environment does not exist.""" 39 def __init__(self, env_name: str) -> None: 40 self.env_name = env_name 41 super().__init__(f'No environment named {env_sty(env_name)}') 42 43class NoPackagesError(MilieuxError): 44 """Error for when no packages are provided.""" 45 46class NoSuchRequirementsFileError(MilieuxError): 47 """Error for when a requirements file does not exist.""" 48 def __init__(self, reqs_path: Union[str, Path]) -> None: 49 self.reqs_path = reqs_path 50 super().__init__(f'No requirements file: {reqs_path}') 51 52class TemplateError(MilieuxError): 53 """Error involving a jinja template.""" 54 55class NoSuchTemplateError(TemplateError): 56 """Error for when a template file does not exist.""" 57 def __init__(self, template_file: Union[str, Path]) -> None: 58 self.template_file = template_file 59 super().__init__(f'Template file {template_file} does not exist')
class
MilieuxError(builtins.ValueError):
Custom class for errors meant to be handled gracefully.
Error for invalid user input.
14class ConfigNotFoundError(MilieuxError): 15 """Error for when the user's config file cannot be found."""
Error for when the user's config file cannot be found.
Error related to a distro.
Error for when a distro already exists.
23class NoSuchDistroError(DistroError): 24 """Error for when a distribution does not exist.""" 25 def __init__(self, distro_name: str) -> None: 26 self.distro_name = distro_name 27 super().__init__(f'No distro named {distro_sty(distro_name)}')
Error for when a distribution does not exist.
Error for when a distro is invalid.
Error related to an environment.
Error for when an environment already exists.
38class NoSuchEnvironmentError(EnvError): 39 """Error for when an environment does not exist.""" 40 def __init__(self, env_name: str) -> None: 41 self.env_name = env_name 42 super().__init__(f'No environment named {env_sty(env_name)}')
Error for when an environment does not exist.
Error for when no packages are provided.
47class NoSuchRequirementsFileError(MilieuxError): 48 """Error for when a requirements file does not exist.""" 49 def __init__(self, reqs_path: Union[str, Path]) -> None: 50 self.reqs_path = reqs_path 51 super().__init__(f'No requirements file: {reqs_path}')
Error for when a requirements file does not exist.
Error involving a jinja template.
56class NoSuchTemplateError(TemplateError): 57 """Error for when a template file does not exist.""" 58 def __init__(self, template_file: Union[str, Path]) -> None: 59 self.template_file = template_file 60 super().__init__(f'Template file {template_file} does not exist')
Error for when a template file does not exist.