Source code for kelvin.sdk.exceptions
"""Shared exceptions for the CLI.
Define base exceptions here. Domain-specific exceptions go in their
respective command modules (e.g., commands/workloads.py).
"""
from typing import Optional
[docs]
class CLIError(Exception):
"""Base exception for all CLI errors.
Subclass this for errors that should show a friendly message
and exit with a specific code.
"""
exit_code: int = 1
message: str = "An error occurred"
def __init__(self, message: Optional[str] = None, exit_code: Optional[int] = None):
self.message = message or self.message
if exit_code is not None:
self.exit_code = exit_code
super().__init__(self.message)
[docs]
class ConfigurationError(CLIError):
"""Missing or invalid configuration."""
exit_code: int = 78 # EX_CONFIG from sysexits.h
[docs]
class AuthenticationError(CLIError):
"""Authentication failed or credentials missing."""
exit_code: int = 77 # EX_NOPERM
[docs]
class NetworkError(CLIError):
"""Network/API communication error."""
exit_code: int = 69 # EX_UNAVAILABLE
# TODO: Add more shared exceptions as needed
# class ValidationError(CLIError):
# """Input validation failed."""
# exit_code = 65 # EX_DATAERR