• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2022 Google Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""Module for errors thrown from snippet client objects."""
15# TODO(mhaoli): Package `mobly.snippet` should not import errors from
16# android_device_lib. However, android_device_lib.DeviceError is the base error
17# for the errors thrown from Android snippet clients and device controllers.
18# We should resolve this legacy problem.
19from mobly.controllers.android_device_lib import errors
20
21
22class Error(errors.DeviceError):
23  """Root error type for snippet clients."""
24
25
26class ServerRestoreConnectionError(Error):
27  """Raised when failed to restore the connection with the snippet server."""
28
29
30class ServerStartError(Error):
31  """Raised when failed to start the snippet server."""
32
33
34class ServerStartProtocolError(ServerStartError):
35  """Raised when protocol reported by the server startup process is unknown."""
36
37
38class ServerStartPreCheckError(Error):
39  """Raised when prechecks for starting the snippet server failed.
40
41  Here are some precheck examples:
42  * Whether the required software is installed on the device.
43  * Whether the configuration file required by the server startup process
44    is available.
45  """
46
47
48class ApiError(Error):
49  """Raised when remote API reported an error."""
50
51
52class ProtocolError(Error):
53  """Raised when there was an error in exchanging data with server."""
54  NO_RESPONSE_FROM_HANDSHAKE = 'No response from handshake.'
55  NO_RESPONSE_FROM_SERVER = ('No response from server. '
56                             'Check the device logcat for crashes.')
57  MISMATCHED_API_ID = 'RPC request-response ID mismatch.'
58  RESPONSE_MISSING_FIELD = 'Missing required field in the RPC response: %s.'
59
60
61class ServerDiedError(Error):
62  """Raised if the snippet server died before all tests finish."""
63
64
65# Error types for callback handlers
66class CallbackHandlerBaseError(errors.DeviceError):
67  """Base error type for snippet clients."""
68
69
70class CallbackHandlerTimeoutError(Error):
71  """Raised if the expected event does not occur within the time limit."""
72