blob: f2c027b8b20b04b51d3b3203784c5d488196f332 [file] [log] [blame]
Sam Chiu81bdc652018-06-29 18:45:08 +08001# Copyright 2018 - The Android Open Source Project
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.
14r"""Custom Exceptions for acloud."""
15
Sam Chiu7de3b232018-12-06 19:45:52 +080016HTTP_NOT_FOUND_CODE = 404
17
18
19class DriverError(Exception):
20 """Base Android Gce driver exception."""
21
22
23class ConfigError(DriverError):
24 """Error related to config."""
25
26
27class CommandArgError(DriverError):
28 """Error related to command line args."""
29
30
31class GceOperationTimeoutError(DriverError):
32 """Error raised when a GCE operation timedout."""
33
34
35class HttpError(DriverError):
36 """Error related to http requests."""
37
38 def __init__(self, code, message):
39 self.code = code
40 super(HttpError, self).__init__(message)
41
42 @staticmethod
43 def CreateFromHttpError(http_error):
44 """Create from an apiclient.errors.HttpError.
45
46 Parse the error code from apiclient.errors.HttpError
47 and create an instance of HttpError from this module
48 that has the error code.
49
50 Args:
51 http_error: An apiclient.errors.HttpError instance.
52
53 Returns:
54 An HttpError instance from this module.
55 """
56 return HttpError(http_error.resp.status, str(http_error))
57
58
59class ResourceNotFoundError(HttpError):
60 """Error raised when a resource is not found."""
61
62
63class InvalidVirtualDeviceIpError(DriverError):
64 """Invalid virtual device's IP is set.
65
66 Raise this when the virtual device's IP of an AVD instance is invalid.
67 """
68
69
70class HasRetriableRequestsError(DriverError):
71 """Raised when some retriable requests fail in a batch execution."""
72
73
74class AuthenticationError(DriverError):
75 """Raised when authentication fails."""
76
77
78class DeviceBootError(DriverError):
79 """To catch device boot errors."""
80
81
82class NoSubnetwork(DriverError):
83 """When there is no subnetwork for the GCE."""
84
85
86class DeviceConnectionError(DriverError):
87 """To catch device connection errors."""
88
89
herbertxue6ef54a52019-05-02 11:38:58 +080090class PortOccupied(DriverError):
91 """Raised when open port fail."""
92
93
Sam Chiu7de3b232018-12-06 19:45:52 +080094class DeviceBootTimeoutError(DeviceBootError):
95 """Raised when an AVD defice failed to boot within timeout."""
96
Sam Chiu81bdc652018-06-29 18:45:08 +080097
98class SetupError(Exception):
99 """Base Setup cmd exception."""
100
101
Sam Chiu7de3b232018-12-06 19:45:52 +0800102class OSTypeError(SetupError):
103 """Error related to OS type."""
104
105
106class NoGoogleSDKDetected(SetupError):
107 """Can't find the SDK path."""
108
109
Sam Chiu81bdc652018-06-29 18:45:08 +0800110class PackageInstallError(SetupError):
111 """Error related to package installation."""
112
113
114class RequiredPackageNotInstalledError(SetupError):
115 """Error related to required package not installed."""
116
117
118class UnableToLocatePkgOnRepositoryError(SetupError):
119 """Error related to unable to locate package."""
120
121
122class NotSupportedPlatformError(SetupError):
123 """Error related to user using a not supported os."""
herbertxue34776bb2018-07-03 21:57:48 +0800124
125
126class ParseBucketRegionError(SetupError):
127 """Raised when parsing bucket information without region information."""
herbertxue2625b042018-08-16 23:28:20 +0800128
129
130class CreateError(Exception):
131 """Base Create cmd exception."""
132
133
Kevin Chenge2580452018-10-05 16:33:56 -0700134class GetAndroidBuildEnvVarError(CreateError):
135 """Can't get Android Build set environment variables."""
herbertxue2625b042018-08-16 23:28:20 +0800136
137
138class CheckPathError(CreateError):
139 """Path does not exist."""
Kevin Cheng3ce4b452018-08-23 14:47:22 -0700140
141
142class UnsupportedInstanceImageType(CreateError):
143 """Unsupported create action for given instance/image type."""
herbertxue79585f42018-08-28 18:36:45 +0800144
145
herbertxuefd15dfd2018-12-04 11:26:27 +0800146class UnsupportedFlavor(CreateError):
147 """Unsupported create action for given flavor name."""
148
149
herbertxue6ef54a52019-05-02 11:38:58 +0800150class UnsupportedMultiAdbPort(CreateError):
151 """Unsupported create action for multi AVDs and specify adb port."""
152
153
herbertxue23b2a962019-07-24 22:39:20 +0800154class UnsupportedCreateArgs(CreateError):
155 """Unsupported create arg for a specified AVD type."""
156
157
herbertxue79585f42018-08-28 18:36:45 +0800158class GetBuildIDError(CreateError):
159 """Can't get build id from Android Build."""
herbertxueb617e8a2018-08-22 10:02:19 +0800160
161
Sam Chiuc64f3432018-08-17 11:19:06 +0800162class NotSupportedHWPropertyError(CreateError):
163 """An error to wrap a non-supported property issue."""
164
165
166class MalformedDictStringError(CreateError):
167 """Error related to unable to convert string to dict."""
168
169
170class InvalidHWPropertyError(CreateError):
171 """An error to wrap a malformed hw property issue."""
cylan1e996c52018-10-01 16:19:50 +0800172
173
174class GetLocalImageError(CreateError):
175 """Can't find the local image."""
176
177
178class GetCvdLocalHostPackageError(CreateError):
179 """Can't find the lost host package."""
chojoycecd004bc2018-09-13 10:39:00 +0800180
181
182class NoCuttlefishCommonInstalled(SetupError):
183 """Can't find cuttlefish_common lib."""
184
185
herbertxuee5b98ae2019-06-19 09:26:17 +0800186class ImgDoesNotExist(CreateError):
187 """Image does not exist."""
chojoycecd004bc2018-09-13 10:39:00 +0800188
189
190class UnsupportedCompressionFileType(SetupError):
191 """Don't support the compression file type."""
Sam Chiuafbc6582018-09-04 20:47:13 +0800192
193
194class LaunchCVDFail(CreateError):
195 """Cuttlefish AVD launch failed."""
cylan66713722018-10-06 01:38:26 +0800196
197
198class NoExecuteCmd(CreateError):
199 """Can't find execute bin command."""
cylan4569dca2018-11-02 12:12:53 +0800200
201
202class ReconnectError(Exception):
203 """Base reconnect cmd exception."""
204
205
206class NoInstancesFound(ReconnectError):
207 """No instances found."""
chojoyceefafc022018-11-08 17:22:16 +0800208
209
210class FunctionTimeoutError(Exception):
211 """Timeout error of decorator function."""
Sam Chiu96172ae2019-01-31 14:30:30 +0800212
213
214class ZipImageError(Exception):
215 """Zip image error."""
cylan694a5d02019-05-11 19:18:31 +0800216
217
218class UnknownAvdType(Exception):
219 """Unknow AVD type."""