1"""Certbot client errors.""" 2from typing import Set 3from typing import TYPE_CHECKING 4 5if TYPE_CHECKING: 6 from certbot.achallenges import AnnotatedChallenge 7 8 9class Error(Exception): 10 """Generic Certbot client error.""" 11 12 13class AccountStorageError(Error): 14 """Generic `.AccountStorage` error.""" 15 16 17class AccountNotFound(AccountStorageError): 18 """Account not found error.""" 19 20 21class ReverterError(Error): 22 """Certbot Reverter error.""" 23 24 25class SubprocessError(Error): 26 """Subprocess handling error.""" 27 28 29class CertStorageError(Error): 30 """Generic `.CertStorage` error.""" 31 32 33class HookCommandNotFound(Error): 34 """Failed to find a hook command in the PATH.""" 35 36 37class SignalExit(Error): 38 """A Unix signal was received while in the ErrorHandler context manager.""" 39 40class OverlappingMatchFound(Error): 41 """Multiple lineages matched what should have been a unique result.""" 42 43class LockError(Error): 44 """File locking error.""" 45 46 47# Auth Handler Errors 48class AuthorizationError(Error): 49 """Authorization error.""" 50 51 52class FailedChallenges(AuthorizationError): 53 """Failed challenges error. 54 55 :ivar set failed_achalls: Failed `.AnnotatedChallenge` instances. 56 57 """ 58 def __init__(self, failed_achalls: Set['AnnotatedChallenge']) -> None: 59 assert failed_achalls 60 self.failed_achalls = failed_achalls 61 super().__init__() 62 63 def __str__(self) -> str: 64 return "Failed authorization procedure. {0}".format( 65 ", ".join( 66 "{0} ({1}): {2}".format(achall.domain, achall.typ, achall.error) 67 for achall in self.failed_achalls if achall.error is not None)) 68 69 70# Plugin Errors 71class PluginError(Error): 72 """Certbot Plugin error.""" 73 74 75class PluginEnhancementAlreadyPresent(Error): 76 """ Enhancement was already set """ 77 78 79class PluginSelectionError(Error): 80 """A problem with plugin/configurator selection or setup""" 81 82 83class NoInstallationError(PluginError): 84 """Certbot No Installation error.""" 85 86 87class MisconfigurationError(PluginError): 88 """Certbot Misconfiguration error.""" 89 90 91class NotSupportedError(PluginError): 92 """Certbot Plugin function not supported error.""" 93 94 95class PluginStorageError(PluginError): 96 """Certbot Plugin Storage error.""" 97 98 99class StandaloneBindError(Error): 100 """Standalone plugin bind error.""" 101 102 def __init__(self, socket_error: OSError, port: int) -> None: 103 super().__init__( 104 "Problem binding to port {0}: {1}".format(port, socket_error)) 105 self.socket_error = socket_error 106 self.port = port 107 108 109class ConfigurationError(Error): 110 """Configuration sanity error.""" 111 112# NoninteractiveDisplay error: 113 114class MissingCommandlineFlag(Error): 115 """A command line argument was missing in noninteractive usage""" 116