From fe4353ec96d73b37018d7b32f6a720dcd5bb097c Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:11:48 +0000 Subject: [PATCH] fix(core): add fallback to absolute imports in error_handler.py --- videoarchiver/core/error_handler.py | 64 ++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/videoarchiver/core/error_handler.py b/videoarchiver/core/error_handler.py index 11b1698..cfb5e00 100644 --- a/videoarchiver/core/error_handler.py +++ b/videoarchiver/core/error_handler.py @@ -14,26 +14,50 @@ from redbot.core.commands import ( # type: ignore CommandError ) -from ..utils.exceptions import ( - VideoArchiverError, - ErrorSeverity, - ErrorContext, - ProcessorError, - ValidationError, - DisplayError, - URLExtractionError, - MessageHandlerError, - QueueHandlerError, - QueueProcessorError, - FFmpegError, - DatabaseError, - HealthCheckError, - TrackingError, - NetworkError, - ResourceExhaustedError, - ConfigurationError -) -from ..core.response_handler import response_manager +try: + # Try relative imports first + from ..utils.exceptions import ( + VideoArchiverError, + ErrorSeverity, + ErrorContext, + ProcessorError, + ValidationError, + DisplayError, + URLExtractionError, + MessageHandlerError, + QueueHandlerError, + QueueProcessorError, + FFmpegError, + DatabaseError, + HealthCheckError, + TrackingError, + NetworkError, + ResourceExhaustedError, + ConfigurationError + ) + from ..core.response_handler import response_manager +except ImportError: + # Fall back to absolute imports if relative imports fail + from videoarchiver.utils.exceptions import ( + VideoArchiverError, + ErrorSeverity, + ErrorContext, + ProcessorError, + ValidationError, + DisplayError, + URLExtractionError, + MessageHandlerError, + QueueHandlerError, + QueueProcessorError, + FFmpegError, + DatabaseError, + HealthCheckError, + TrackingError, + NetworkError, + ResourceExhaustedError, + ConfigurationError + ) + from videoarchiver.core.response_handler import response_manager logger = logging.getLogger("VideoArchiver")