Alias error classes of snippet client v1 to the new ones in snippet package (#824)
diff --git a/mobly/controllers/android_device_lib/jsonrpc_client_base.py b/mobly/controllers/android_device_lib/jsonrpc_client_base.py
index 7d7e3a1..7f27fa5 100644
--- a/mobly/controllers/android_device_lib/jsonrpc_client_base.py
+++ b/mobly/controllers/android_device_lib/jsonrpc_client_base.py
@@ -57,7 +57,7 @@
import threading
from mobly.controllers.android_device_lib import callback_handler
-from mobly.controllers.android_device_lib import errors
+from mobly.snippet import errors
# UID of the 'unknown' jsonrpc session. Will cause creation of a new session.
UNKNOWN_UID = -1
@@ -72,29 +72,12 @@
# off.
_MAX_RPC_RESP_LOGGING_LENGTH = 1024
-
-class Error(errors.DeviceError):
- pass
-
-
-class AppStartError(Error):
- """Raised when the app is not able to be started."""
-
-
-class AppRestoreConnectionError(Error):
- """Raised when failed to restore app from disconnection."""
-
-
-class ApiError(Error):
- """Raised when remote API reports an error."""
-
-
-class ProtocolError(Error):
- """Raised when there is some error in exchanging data with server."""
- NO_RESPONSE_FROM_HANDSHAKE = 'No response from handshake.'
- NO_RESPONSE_FROM_SERVER = ('No response from server. '
- 'Check the device logcat for crashes.')
- MISMATCHED_API_ID = 'RPC request-response ID mismatch.'
+# Aliases of error types for backward compatibility.
+Error = errors.Error
+AppStartError = errors.ServerStartError
+AppRestoreConnectionError = errors.ServerRestoreConnectionError
+ApiError = errors.ApiError
+ProtocolError = errors.ProtocolError
class JsonRpcCommand:
diff --git a/mobly/controllers/android_device_lib/snippet_client.py b/mobly/controllers/android_device_lib/snippet_client.py
index c0dbadc..330bf43 100644
--- a/mobly/controllers/android_device_lib/snippet_client.py
+++ b/mobly/controllers/android_device_lib/snippet_client.py
@@ -20,6 +20,7 @@
from mobly.controllers.android_device_lib import adb
from mobly.controllers.android_device_lib import errors
from mobly.controllers.android_device_lib import jsonrpc_client_base
+from mobly.snippet import errors as snippet_errors
_INSTRUMENTATION_RUNNER_PACKAGE = (
'com.google.android.mobly.snippet.SnippetRunner')
@@ -56,13 +57,9 @@
_NOHUP_COMMAND = 'nohup'
-
-class AppStartPreCheckError(jsonrpc_client_base.Error):
- """Raised when pre checks for the snippet failed."""
-
-
-class ProtocolVersionError(jsonrpc_client_base.AppStartError):
- """Raised when the protocol reported by the snippet is unknown."""
+# Aliases of error types for backward compatibility.
+AppStartPreCheckError = snippet_errors.ServerStartPreCheckError
+ProtocolVersionError = snippet_errors.ServerStartProtocolError
class SnippetClient(jsonrpc_client_base.JsonRpcClientBase):