blob: 09a2c0d41e375da345359a9181ac23d2fa58d01d [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
90class DeviceBootTimeoutError(DeviceBootError):
91 """Raised when an AVD defice failed to boot within timeout."""
92
Sam Chiu81bdc652018-06-29 18:45:08 +080093
94class SetupError(Exception):
95 """Base Setup cmd exception."""
96
97
Sam Chiu7de3b232018-12-06 19:45:52 +080098class OSTypeError(SetupError):
99 """Error related to OS type."""
100
101
102class NoGoogleSDKDetected(SetupError):
103 """Can't find the SDK path."""
104
105
Sam Chiu81bdc652018-06-29 18:45:08 +0800106class PackageInstallError(SetupError):
107 """Error related to package installation."""
108
109
110class RequiredPackageNotInstalledError(SetupError):
111 """Error related to required package not installed."""
112
113
114class UnableToLocatePkgOnRepositoryError(SetupError):
115 """Error related to unable to locate package."""
116
117
118class NotSupportedPlatformError(SetupError):
119 """Error related to user using a not supported os."""
herbertxue34776bb2018-07-03 21:57:48 +0800120
121
122class ParseBucketRegionError(SetupError):
123 """Raised when parsing bucket information without region information."""
herbertxue2625b042018-08-16 23:28:20 +0800124
125
126class CreateError(Exception):
127 """Base Create cmd exception."""
128
129
Kevin Chenge2580452018-10-05 16:33:56 -0700130class GetAndroidBuildEnvVarError(CreateError):
131 """Can't get Android Build set environment variables."""
herbertxue2625b042018-08-16 23:28:20 +0800132
133
134class CheckPathError(CreateError):
135 """Path does not exist."""
Kevin Cheng3ce4b452018-08-23 14:47:22 -0700136
137
138class UnsupportedInstanceImageType(CreateError):
139 """Unsupported create action for given instance/image type."""
herbertxue79585f42018-08-28 18:36:45 +0800140
141
herbertxuefd15dfd2018-12-04 11:26:27 +0800142class UnsupportedFlavor(CreateError):
143 """Unsupported create action for given flavor name."""
144
145
herbertxue79585f42018-08-28 18:36:45 +0800146class GetBuildIDError(CreateError):
147 """Can't get build id from Android Build."""
herbertxueb617e8a2018-08-22 10:02:19 +0800148
149
150class GetBranchFromRepoInfoError(CreateError):
151 """Can't get branch information from output of #'repo info'."""
Sam Chiuc64f3432018-08-17 11:19:06 +0800152
153
154class NotSupportedHWPropertyError(CreateError):
155 """An error to wrap a non-supported property issue."""
156
157
158class MalformedDictStringError(CreateError):
159 """Error related to unable to convert string to dict."""
160
161
162class InvalidHWPropertyError(CreateError):
163 """An error to wrap a malformed hw property issue."""
cylan1e996c52018-10-01 16:19:50 +0800164
165
166class GetLocalImageError(CreateError):
167 """Can't find the local image."""
168
169
170class GetCvdLocalHostPackageError(CreateError):
171 """Can't find the lost host package."""
chojoycecd004bc2018-09-13 10:39:00 +0800172
173
174class NoCuttlefishCommonInstalled(SetupError):
175 """Can't find cuttlefish_common lib."""
176
177
178class UnpackBootImageError(CreateError):
179 """Error related to unpack boot.img."""
180
181
182class BootImgDoesNotExist(CreateError):
183 """boot.img does not exist."""
184
185
186class UnsupportedCompressionFileType(SetupError):
187 """Don't support the compression file type."""
Sam Chiuafbc6582018-09-04 20:47:13 +0800188
189
190class LaunchCVDFail(CreateError):
191 """Cuttlefish AVD launch failed."""
cylan66713722018-10-06 01:38:26 +0800192
193
194class NoExecuteCmd(CreateError):
195 """Can't find execute bin command."""
cylan4569dca2018-11-02 12:12:53 +0800196
197
198class ReconnectError(Exception):
199 """Base reconnect cmd exception."""
200
201
202class NoInstancesFound(ReconnectError):
203 """No instances found."""
chojoyceefafc022018-11-08 17:22:16 +0800204
205
206class FunctionTimeoutError(Exception):
207 """Timeout error of decorator function."""
Sam Chiu96172ae2019-01-31 14:30:30 +0800208
209
210class ZipImageError(Exception):
211 """Zip image error."""