Skip to content

Commit

Permalink
Exception Hierarchy:
Browse files Browse the repository at this point in the history
Added missing exceptions to utils/exceptions.py:
ResourceExhaustedError
ProcessingError
CleanupError
FileOperationError
Fixed exception imports in exceptions.py
Added proper re-exports of all exceptions
Maintained backward compatibility aliases
URL Processing:

Added pre-filtering for URLs before yt-dlp checks
Added common video platform patterns
Reduced error logging noise
Improved URL validation efficiency
Error Handling:

Added proper error types for all operations
Enhanced error messages with context
Added resource exhaustion checks
Improved error propagation
Code Organization:

Centralized exceptions in utils/exceptions.py
Proper re-exports in exceptions.py
Consistent error handling across components
Better error type hierarchy
  • Loading branch information
pacnpal committed Nov 15, 2024
1 parent 074b6b2 commit 4e8eb38
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
28 changes: 24 additions & 4 deletions videoarchiver/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,43 @@
VideoVerificationError,
QueueError,
FileCleanupError,
ResourceExhaustedError,
ProcessingError,
CleanupError,
FileOperationError,
VideoDownloadError,
VideoProcessingError,
VideoUploadError,
VideoCleanupError,
PermissionError,
NetworkError,
ResourceError,
ComponentError,
DiscordAPIError,
)

# Re-export base exceptions
# Re-export all exceptions
__all__ = [
'VideoArchiverError',
'ConfigurationError',
'VideoVerificationError',
'QueueError',
'FileCleanupError',
'UpdateError',
'ResourceExhaustedError',
'ProcessingError',
'ConfigError',
'CleanupError',
'FileOperationError',
'VideoDownloadError',
'VideoProcessingError',
'VideoUploadError',
'VideoCleanupError',
'PermissionError',
'NetworkError',
'ResourceError',
'ComponentError',
'DiscordAPIError',
]

# Alias exceptions for backward compatibility
ProcessingError = VideoArchiverError
ConfigError = ConfigurationError
UpdateError = VideoVerificationError
18 changes: 18 additions & 0 deletions videoarchiver/utils/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,21 @@ class DiscordAPIError(VideoArchiverError):
def __init__(self, message: str, status_code: int = None):
self.status_code = status_code
super().__init__(f"Discord API Error: {message} (Status: {status_code if status_code else 'Unknown'})")

class ResourceExhaustedError(VideoArchiverError):
"""Error when system resources are exhausted"""
def __init__(self, message: str, resource_type: str = None):
self.resource_type = resource_type
super().__init__(f"Resource exhausted: {message} (Type: {resource_type if resource_type else 'Unknown'})")

class ProcessingError(VideoArchiverError):
"""Error during video processing"""
pass

class CleanupError(VideoArchiverError):
"""Error during cleanup operations"""
pass

class FileOperationError(VideoArchiverError):
"""Error during file operations"""
pass

0 comments on commit 4e8eb38

Please sign in to comment.