Spaces:
Sleeping
Sleeping
File size: 997 Bytes
2f1a5fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | from __future__ import annotations
from .exceptions import (
AuthenticationError,
RepositoryError,
SessionError,
UploaderCliError,
UploadError,
ValidationError,
)
ERROR_HINTS: dict[type[UploaderCliError], str] = {
AuthenticationError: "Run 'birdnet-uploader login' and verify your Hugging Face token.",
RepositoryError: "Check repository id format (owner/name) and write permissions on Hugging Face.",
SessionError: "Verify session id and local checkpoint files under .birdnet-uploader/sessions.",
ValidationError: "Fix invalid paths or inputs and retry the command.",
UploadError: "Check your network and run the command again to resume from checkpoint.",
}
def build_error_message(error: Exception) -> str:
if isinstance(error, UploaderCliError):
hint = error.suggestion or ERROR_HINTS.get(type(error), "")
if hint:
return f"{error} Hint: {hint}"
return str(error)
return f"Unexpected error: {error}"
|