Spaces:
Sleeping
Sleeping
Download src/uploader/error_handler.py from jrrribeiro/BirdNET-Uploader-App: direct link, hf CLI and curl.
- Browser
- Download file 997 Bytes
-
https://huggingface.co/spaces/jrrribeiro/BirdNET-Uploader-App/resolve/main/src/uploader/error_handler.py
- Command line
-
hf download hf://spaces/jrrribeiro/BirdNET-Uploader-App/src/uploader/error_handler.py
-
curl -L -o error_handler.py https://huggingface.co/spaces/jrrribeiro/BirdNET-Uploader-App/resolve/main/src/uploader/error_handler.py
997 Bytes
| 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}" | |