MikeChandler's picture
feat: initial release of hf-release v0.1.0
f824e2f verified
"""Custom exception hierarchy for hf-release."""
from __future__ import annotations
class HFReleaseError(Exception):
"""Base exception for all hf-release errors."""
exit_code: int = 1
def __init__(self, message: str, suggestion: str = "") -> None:
super().__init__(message)
self.suggestion = suggestion
class AuthenticationError(HFReleaseError):
"""Raised when a token is missing or invalid."""
exit_code = 2
class RepoNotFoundError(HFReleaseError):
"""Raised when a HF or GitHub repo does not exist."""
exit_code = 3
class TagConflictError(HFReleaseError):
"""Raised when a tag already exists with a different SHA."""
exit_code = 4
class ModelCardSyncError(HFReleaseError):
"""Raised when reading or pushing a model card fails."""
exit_code = 5
class UploadError(HFReleaseError):
"""Raised when uploading model weights to HF Hub fails."""
exit_code = 6
class ReleaseCreationError(HFReleaseError):
"""Raised when creating a GitHub release fails."""
exit_code = 7
class ValidationError(HFReleaseError):
"""Raised for bad input (invalid version string, missing path, etc.)."""
exit_code = 8