40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
"""Shared exceptions for sn-image-base."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
class U1BaseError(Exception):
|
|
"""Base exception for sn-image-base."""
|
|
|
|
DEFAULT_MESSAGE = "An error occurred in the sn-image-base skill."
|
|
|
|
def __init__(self, message: str | None = None) -> None:
|
|
if message is None:
|
|
message = self.DEFAULT_MESSAGE
|
|
super().__init__(message)
|
|
|
|
|
|
class BadConfigurationError(U1BaseError):
|
|
"""Raised when the configuration is invalid."""
|
|
|
|
DEFAULT_MESSAGE = "The configuration is invalid."
|
|
|
|
|
|
class MissingApiKeyError(BadConfigurationError):
|
|
"""Raised when API key is not provided via CLI argument or environment variable."""
|
|
|
|
DEFAULT_MESSAGE = (
|
|
"API key is required but was not provided. "
|
|
"Set SN_API_KEY, or set SN_IMAGE_GEN_API_KEY only for an image-generation-specific "
|
|
"override, or pass --api-key explicitly."
|
|
)
|
|
|
|
|
|
class InvalidBaseUrlError(BadConfigurationError):
|
|
"""Raised when base URL is not provided via CLI argument or environment variable."""
|
|
|
|
DEFAULT_MESSAGE = (
|
|
"Base URL is required but was not provided. "
|
|
"Set SN_IMAGE_GEN_BASE_URL or SN_BASE_URL, or pass --base-url explicitly."
|
|
)
|