From efd374720cc1265cd954619152699ce5250a37e8 Mon Sep 17 00:00:00 2001 From: MacbookPro-14 Date: Fri, 29 Dec 2023 21:25:37 +0800 Subject: [PATCH] Update version number and add ConnectionClosedError exception --- setup.cfg | 2 +- src/aselenium/__init__.py | 3 ++- src/aselenium/errors.py | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/setup.cfg b/setup.cfg index e7411ce..8bd21ad 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = aselenium -version = 0.1.12.7 +version = 0.1.12.8 author = Jiefu Chen author_email = keppa1991@163.com description = Asyncronous implementation of web browser automation for Python. diff --git a/src/aselenium/__init__.py b/src/aselenium/__init__.py index 3191dec..33e526b 100644 --- a/src/aselenium/__init__.py +++ b/src/aselenium/__init__.py @@ -111,6 +111,7 @@ WebDriverError, WebDriverTimeoutError, WebdriverNotFoundError, + ConnectionClosedError, InternetDisconnectedError, InvalidValueError, InvalidArgumentError, @@ -209,7 +210,7 @@ "ServiceError", "ServiceExecutableNotFoundError", "ServiceStartError", "ServiceStopError", "ServiceSocketError", "ServiceProcessError", "ServiceTimeoutError", # . webdriver - "WebDriverError", "WebDriverTimeoutError", "WebdriverNotFoundError", "InternetDisconnectedError", + "WebDriverError", "WebDriverTimeoutError", "WebdriverNotFoundError", "ConnectionClosedError", "InternetDisconnectedError", "InvalidValueError", "InvalidArgumentError", "InvalidMethodError", "InvalidRectValueError", "InvalidResponseError", "InvalidExtensionError", "UnknownMethodError", "SessionError", "SessionClientError", "InvalidSessionError", "IncompatibleWebdriverError", "SessionDataError", diff --git a/src/aselenium/errors.py b/src/aselenium/errors.py index bb568b9..fc8b7cb 100644 --- a/src/aselenium/errors.py +++ b/src/aselenium/errors.py @@ -204,14 +204,14 @@ class WebdriverNotFoundError(WebDriverError): """Exception raised when target not found.""" -class InternetDisconnectedError(WebDriverError): - """Exception raised when internet disconnected.""" - - class ConnectionClosedError(WebDriverError): """Exception raised when connection closed.""" +class InternetDisconnectedError(WebDriverError): + """Exception raised when internet disconnected.""" + + # . Inavlid value error class InvalidValueError(WebDriverError, AseleniumInvalidValueError): """Base exception class for all invalid value errors.""" @@ -779,10 +779,10 @@ def webdriver_error_handler(res: dict[str, Any]) -> None: if error is UnknownError: if ErrorCode.FAILED_TO_CHANGE_WINDOW_STATE in message: error = ChangeWindowStateError - elif ErrorCode.INTERNET_DISCONNECTED in message: - error = InternetDisconnectedError elif ErrorCode.CONNECTION_CLOSED in message: error = ConnectionClosedError + elif ErrorCode.INTERNET_DISCONNECTED in message: + error = InternetDisconnectedError elif error is InvalidSessionError: if INCOMPATIBLE_DRIVER_PATTERN.search(message) is not None: error = IncompatibleWebdriverError