blob: 6dcd83ecc2030cfe0dfea6bd501ee2ac8208488f [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
herbertxue7a501212019-08-29 15:37:13 +080035class GetGceZoneError(DriverError):
36 """Can't get GCE zones info."""
37
38
Sam Chiu7de3b232018-12-06 19:45:52 +080039class HttpError(DriverError):
40 """Error related to http requests."""
41
42 def __init__(self, code, message):
43 self.code = code
44 super(HttpError, self).__init__(message)
45
46 @staticmethod
47 def CreateFromHttpError(http_error):
48 """Create from an apiclient.errors.HttpError.
49
50 Parse the error code from apiclient.errors.HttpError
51 and create an instance of HttpError from this module
52 that has the error code.
53
54 Args:
55 http_error: An apiclient.errors.HttpError instance.
56
57 Returns:
58 An HttpError instance from this module.
59 """
60 return HttpError(http_error.resp.status, str(http_error))
61
62
63class ResourceNotFoundError(HttpError):
64 """Error raised when a resource is not found."""
65
66
67class InvalidVirtualDeviceIpError(DriverError):
68 """Invalid virtual device's IP is set.
69
70 Raise this when the virtual device's IP of an AVD instance is invalid.
71 """
72
73
74class HasRetriableRequestsError(DriverError):
75 """Raised when some retriable requests fail in a batch execution."""
76
77
78class AuthenticationError(DriverError):
79 """Raised when authentication fails."""
80
81
82class DeviceBootError(DriverError):
83 """To catch device boot errors."""
84
85
86class NoSubnetwork(DriverError):
87 """When there is no subnetwork for the GCE."""
88
89
90class DeviceConnectionError(DriverError):
91 """To catch device connection errors."""
92
93
herbertxue6ef54a52019-05-02 11:38:58 +080094class PortOccupied(DriverError):
95 """Raised when open port fail."""
96
97
Sam Chiu7de3b232018-12-06 19:45:52 +080098class DeviceBootTimeoutError(DeviceBootError):
99 """Raised when an AVD defice failed to boot within timeout."""
100
Sam Chiu81bdc652018-06-29 18:45:08 +0800101
102class SetupError(Exception):
103 """Base Setup cmd exception."""
104
105
Sam Chiu7de3b232018-12-06 19:45:52 +0800106class OSTypeError(SetupError):
107 """Error related to OS type."""
108
109
110class NoGoogleSDKDetected(SetupError):
111 """Can't find the SDK path."""
112
113
herbertxued69dc512019-05-30 15:37:15 +0800114class NoBillingError(SetupError):
115 """Billing account isn't enabled."""
116
117
Sam Chiu81bdc652018-06-29 18:45:08 +0800118class PackageInstallError(SetupError):
119 """Error related to package installation."""
120
121
122class RequiredPackageNotInstalledError(SetupError):
123 """Error related to required package not installed."""
124
125
126class UnableToLocatePkgOnRepositoryError(SetupError):
127 """Error related to unable to locate package."""
128
129
130class NotSupportedPlatformError(SetupError):
131 """Error related to user using a not supported os."""
herbertxue34776bb2018-07-03 21:57:48 +0800132
133
herbertxue2625b042018-08-16 23:28:20 +0800134class CreateError(Exception):
135 """Base Create cmd exception."""
136
137
Kevin Chenge2580452018-10-05 16:33:56 -0700138class GetAndroidBuildEnvVarError(CreateError):
139 """Can't get Android Build set environment variables."""
herbertxue2625b042018-08-16 23:28:20 +0800140
141
142class CheckPathError(CreateError):
143 """Path does not exist."""
Kevin Cheng3ce4b452018-08-23 14:47:22 -0700144
145
herbertxue66c1b952020-01-01 14:38:06 +0800146class CheckGCEZonesQuotaError(CreateError):
147 """There is no zone have enough quota."""
148
149
Kevin Cheng3ce4b452018-08-23 14:47:22 -0700150class UnsupportedInstanceImageType(CreateError):
151 """Unsupported create action for given instance/image type."""
herbertxue79585f42018-08-28 18:36:45 +0800152
153
herbertxuefd15dfd2018-12-04 11:26:27 +0800154class UnsupportedFlavor(CreateError):
155 """Unsupported create action for given flavor name."""
156
157
herbertxue6ef54a52019-05-02 11:38:58 +0800158class UnsupportedMultiAdbPort(CreateError):
159 """Unsupported create action for multi AVDs and specify adb port."""
160
161
herbertxue23b2a962019-07-24 22:39:20 +0800162class UnsupportedCreateArgs(CreateError):
163 """Unsupported create arg for a specified AVD type."""
164
165
herbertxue79585f42018-08-28 18:36:45 +0800166class GetBuildIDError(CreateError):
167 """Can't get build id from Android Build."""
herbertxueb617e8a2018-08-22 10:02:19 +0800168
169
Sam Chiuc64f3432018-08-17 11:19:06 +0800170class NotSupportedHWPropertyError(CreateError):
171 """An error to wrap a non-supported property issue."""
172
173
174class MalformedDictStringError(CreateError):
175 """Error related to unable to convert string to dict."""
176
177
178class InvalidHWPropertyError(CreateError):
179 """An error to wrap a malformed hw property issue."""
cylan1e996c52018-10-01 16:19:50 +0800180
181
182class GetLocalImageError(CreateError):
183 """Can't find the local image."""
184
185
186class GetCvdLocalHostPackageError(CreateError):
187 """Can't find the lost host package."""
chojoycecd004bc2018-09-13 10:39:00 +0800188
189
Hsin-Yi Chen7ba49962019-09-25 18:58:56 +0800190class GetSdkRepoPackageError(CreateError):
191 """Can't find the local SDK repository package for goldfish."""
192
193
chojoycecd004bc2018-09-13 10:39:00 +0800194class NoCuttlefishCommonInstalled(SetupError):
195 """Can't find cuttlefish_common lib."""
196
197
herbertxuee5b98ae2019-06-19 09:26:17 +0800198class ImgDoesNotExist(CreateError):
199 """Image does not exist."""
chojoycecd004bc2018-09-13 10:39:00 +0800200
201
202class UnsupportedCompressionFileType(SetupError):
203 """Don't support the compression file type."""
Sam Chiuafbc6582018-09-04 20:47:13 +0800204
205
206class LaunchCVDFail(CreateError):
207 """Cuttlefish AVD launch failed."""
cylan66713722018-10-06 01:38:26 +0800208
209
Hsin-Yi Chen2a609332019-10-07 19:39:52 +0800210class SubprocessFail(CreateError):
211 """Subprocess failed."""
Hsin-Yi Chen7ba49962019-09-25 18:58:56 +0800212
213
cylan66713722018-10-06 01:38:26 +0800214class NoExecuteCmd(CreateError):
215 """Can't find execute bin command."""
cylan4569dca2018-11-02 12:12:53 +0800216
217
218class ReconnectError(Exception):
219 """Base reconnect cmd exception."""
220
221
222class NoInstancesFound(ReconnectError):
223 """No instances found."""
chojoyceefafc022018-11-08 17:22:16 +0800224
225
226class FunctionTimeoutError(Exception):
227 """Timeout error of decorator function."""
Sam Chiu96172ae2019-01-31 14:30:30 +0800228
229
230class ZipImageError(Exception):
231 """Zip image error."""
cylan694a5d02019-05-11 19:18:31 +0800232
233
234class UnknownAvdType(Exception):
herbertxue61bfd972019-09-24 15:51:52 +0800235 """Unknown AVD type."""
236
cylana49c1762019-09-02 12:14:07 +0800237
238class UnknownType(Exception):
herbertxue61bfd972019-09-24 15:51:52 +0800239 """Unknown type."""
Sam Chiu59120542019-08-15 09:32:32 +0800240
241
242class AdbDisconnectFailed(Exception):
243 """Adb still be alive after disconnect instance."""
244
245
246class UnsupportedLocalInstanceId(Exception):
247 """Unsupported local instance id."""
Sam Chiu34e752e2019-08-16 18:15:36 +0800248
249
250class InvalidInstanceDir(Exception):
251 """Invalid instance dir."""