harbor_cli.exceptions
Attributes
MESSAGE_BADREQUEST = '400 Bad request: {method} {url}. Check your input. If you think this is a bug, please report it.'
module-attribute
MESSAGE_UNAUTHORIZED = '401 Unauthorized: {method} {url}. Check your credentials.'
module-attribute
MESSAGE_FORBIDDEN = '403 Forbidden: {method} {url}. Make sure you have permissions to access the resource.'
module-attribute
MESSAGE_NOTFOUND = '404 Not Found: {method} {url}. Resource not found.'
module-attribute
MESSAGE_METHODNOTALLOWED = '405 Method Not Allowed: {method} {url}. This is either a bug, or a problem with your server or credentials.'
module-attribute
MESSAGE_CONFLICT = '409 Conflict: {method} {url}. Resource already exists.'
module-attribute
MESSAGE_PRECONDITIONFAILED = '412 Precondition Failed: {method} {url} Check your input. If you think this is a bug, please report it.'
module-attribute
MESSAGE_UNSUPPORTEDMEDIATYPE = '415 Unsupported Media Type: {method} {url}. Check your input. If you think this is a bug, please report it.'
module-attribute
MESSAGE_INTERNALSERVERERROR = '500 Internal Server Error: {method} {url}. Check your input. If you think this is a bug, please report it.'
module-attribute
MESSAGE_MAPPING: Dict[Type[Exception], str] = {BadRequest: MESSAGE_BADREQUEST, Unauthorized: MESSAGE_UNAUTHORIZED, Forbidden: MESSAGE_FORBIDDEN, NotFound: MESSAGE_NOTFOUND, MethodNotAllowed: MESSAGE_METHODNOTALLOWED, Conflict: MESSAGE_CONFLICT, PreconditionFailed: MESSAGE_PRECONDITIONFAILED, UnsupportedMediaType: MESSAGE_UNSUPPORTEDMEDIATYPE, InternalServerError: MESSAGE_INTERNALSERVERERROR}
module-attribute
EXC_HANDLERS: Mapping[Type[Exception], HandleFunc] = {ValidationError: handle_validationerror, StatusError: handle_status_error, HarborCLIError: handle_notraceback, HTTPError: handle_notraceback, InvalidURL: handle_notraceback, CookieConflict: handle_notraceback, StreamError: handle_notraceback, KeyringError: handle_keyring_error}
module-attribute
Classes
HarborCLIError
ConfigError
Bases: HarborCLIError
Error loading the configuration file.
ConfigFileNotFoundError
Bases: ConfigError
, FileNotFoundError
Configuration file not found.
DirectoryCreateError
Bases: HarborCLIError
, OSError
Error creating a required program directory.
CredentialsError
Bases: HarborCLIError
Error loading credentials.
OverwriteError
Bases: HarborCLIError
, FileExistsError
Error overwriting an existing file.
KeyringUnsupportedError
Bases: HarborCLIError
Keyring is not supported on this system.
ArtifactNameFormatError
Bases: HarborCLIError
Source code in harbor_cli/exceptions.py
Exiter
Bases: Protocol
Protocol class for exit function that can be passed to an exception handler function.
See Also
Source code in harbor_cli/exceptions.py
HandleFunc
Bases: Protocol
Interface for exception handler functions.
They take any exception and an Exiter function as the arguments and exit with the appropriate message after running any necessary cleanup and/or logging.
Source code in harbor_cli/exceptions.py
Functions
__call__(e: Any, exiter: Exiter) -> NoReturn
Source code in harbor_cli/exceptions.py
Default
Dict subclass used for str.format_map() to provide default. Missing keys are replaced with the key surrounded by curly braces.
Source code in harbor_cli/exceptions.py
Functions
handle_status_error(e: StatusError, exiter: Exiter) -> NoReturn
Handles an HTTP status error from the Harbor API and exits with the appropriate message.
Source code in harbor_cli/exceptions.py
handle_keyring_error(e: KeyringError, exiter: Exiter) -> NoReturn
Handles a keyring error and exits with the appropriate message.
Source code in harbor_cli/exceptions.py
handle_validationerror(e: ValidationError, exiter: Exiter) -> NoReturn
Handles a pydantic ValidationError and exits with the appropriate message.
handle_notraceback(e: HarborCLIError, exiter: Exiter) -> NoReturn
get_exception_handler(type_: Type[Exception]) -> Optional[HandleFunc]
Returns the exception handler for the given exception type.
Source code in harbor_cli/exceptions.py
handle_exception(e: Exception) -> NoReturn
Handles an exception and exits with the appropriate message.