blob: 822a4bb5bad3976fe800399b51f328f07304dc25 [file] [log] [blame]
Aviv Keshet39164ca2013-03-27 15:08:33 -07001#pylint: disable-msg=C0111
2
mbligh906b9f72007-11-29 18:56:17 +00003"""
4Internal global error types
5"""
6
Richard Barnettec32ef4d2016-04-21 12:31:05 -07007import sys, traceback
mbligh906b9f72007-11-29 18:56:17 +00008from traceback import format_exception
9
mbligh91672252008-10-16 22:28:34 +000010# Add names you want to be imported by 'from errors import *' to this list.
11# This must be list not a tuple as we modify it to include all of our
12# the Exception classes we define below at the end of this file.
Richard Barnettec32ef4d2016-04-21 12:31:05 -070013__all__ = ['format_error']
mbligh91672252008-10-16 22:28:34 +000014
15
mbligh906b9f72007-11-29 18:56:17 +000016def format_error():
jadmanski0afbb632008-06-06 21:10:57 +000017 t, o, tb = sys.exc_info()
18 trace = format_exception(t, o, tb)
19 # Clear the backtrace to prevent a circular reference
20 # in the heap -- as per tutorial
21 tb = ''
mbligh906b9f72007-11-29 18:56:17 +000022
jadmanski0afbb632008-06-06 21:10:57 +000023 return ''.join(trace)
mbligh906b9f72007-11-29 18:56:17 +000024
mbligh4f407462008-12-03 15:22:39 +000025
beeps60aec242013-06-26 14:47:48 -070026class TimeoutException(Exception):
Aviv Keshet6dec0e12017-04-17 15:23:33 -070027 """Generic exception raised on retry timeouts."""
beeps60aec242013-06-26 14:47:48 -070028
29
mbligh906b9f72007-11-29 18:56:17 +000030class JobContinue(SystemExit):
jadmanski0afbb632008-06-06 21:10:57 +000031 """Allow us to bail out requesting continuance."""
mbligh906b9f72007-11-29 18:56:17 +000032
mbligh7e1b1502008-06-06 15:05:41 +000033
mbligh906b9f72007-11-29 18:56:17 +000034class JobComplete(SystemExit):
jadmanski0afbb632008-06-06 21:10:57 +000035 """Allow us to bail out indicating continuation not required."""
mbligh906b9f72007-11-29 18:56:17 +000036
mbligh7e1b1502008-06-06 15:05:41 +000037
mbligh906b9f72007-11-29 18:56:17 +000038class AutotestError(Exception):
jadmanski0afbb632008-06-06 21:10:57 +000039 """The parent of all errors deliberatly thrown within the client code."""
mbligh906b9f72007-11-29 18:56:17 +000040
mbligh7e1b1502008-06-06 15:05:41 +000041
mbligh906b9f72007-11-29 18:56:17 +000042class JobError(AutotestError):
mbligh4f407462008-12-03 15:22:39 +000043 """Indicates an error which terminates and fails the whole job (ABORT)."""
mbligh906b9f72007-11-29 18:56:17 +000044
mbligh7e1b1502008-06-06 15:05:41 +000045
mbligh4f407462008-12-03 15:22:39 +000046class UnhandledJobError(JobError):
47 """Indicates an unhandled error in a job."""
48 def __init__(self, unhandled_exception):
49 if isinstance(unhandled_exception, JobError):
mbligh1ca1c2c2008-12-09 23:38:25 +000050 JobError.__init__(self, *unhandled_exception.args)
Luis Hector Chavez9c4a4332017-03-30 13:12:28 -070051 elif isinstance(unhandled_exception, basestring):
Eric Li861b2d52011-02-04 14:50:35 -080052 JobError.__init__(self, unhandled_exception)
mbligh4f407462008-12-03 15:22:39 +000053 else:
54 msg = "Unhandled %s: %s"
55 msg %= (unhandled_exception.__class__.__name__,
56 unhandled_exception)
mbligh4f407462008-12-03 15:22:39 +000057 msg += "\n" + traceback.format_exc()
58 JobError.__init__(self, msg)
59
60
mblighc2180832008-07-25 03:26:12 +000061class TestBaseException(AutotestError):
62 """The parent of all test exceptions."""
mbligh021679f2008-11-27 00:43:19 +000063 # Children are required to override this. Never instantiate directly.
Alex Miller30837902013-02-02 15:52:43 -080064 exit_status = "NEVER_RAISE_THIS"
mblighc2180832008-07-25 03:26:12 +000065
66
67class TestError(TestBaseException):
mblighb48fa562008-06-23 17:29:40 +000068 """Indicates that something went wrong with the test harness itself."""
Alex Miller30837902013-02-02 15:52:43 -080069 exit_status = "ERROR"
mblighb48fa562008-06-23 17:29:40 +000070
jadmanski8d01bfe2008-06-23 18:13:24 +000071
mblighc2180832008-07-25 03:26:12 +000072class TestNAError(TestBaseException):
jadmanski0afbb632008-06-06 21:10:57 +000073 """Indictates that the test is Not Applicable. Should be thrown
mblighb48fa562008-06-23 17:29:40 +000074 when various conditions are such that the test is inappropriate."""
Alex Miller30837902013-02-02 15:52:43 -080075 exit_status = "TEST_NA"
mblighb48fa562008-06-23 17:29:40 +000076
jadmanski8d01bfe2008-06-23 18:13:24 +000077
mblighc2180832008-07-25 03:26:12 +000078class TestFail(TestBaseException):
mblighb48fa562008-06-23 17:29:40 +000079 """Indicates that the test failed, but the job will not continue."""
Alex Miller30837902013-02-02 15:52:43 -080080 exit_status = "FAIL"
mblighb48fa562008-06-23 17:29:40 +000081
jadmanski8d01bfe2008-06-23 18:13:24 +000082
mblighc2180832008-07-25 03:26:12 +000083class TestWarn(TestBaseException):
mblighb48fa562008-06-23 17:29:40 +000084 """Indicates that bad things (may) have happened, but not an explicit
85 failure."""
Alex Miller30837902013-02-02 15:52:43 -080086 exit_status = "WARN"
mbligh6a2a2df2008-01-16 17:41:55 +000087
mbligh7e1b1502008-06-06 15:05:41 +000088
Aviv Keshet39164ca2013-03-27 15:08:33 -070089class TestFailRetry(TestFail):
90 """Indicates that the test failed, but in a manner that may be retried
91 if test retries are enabled for this test."""
92 exit_status = "FAIL"
93
94
mblighc2180832008-07-25 03:26:12 +000095class UnhandledTestError(TestError):
96 """Indicates an unhandled error in a test."""
97 def __init__(self, unhandled_exception):
98 if isinstance(unhandled_exception, TestError):
99 TestError.__init__(self, *unhandled_exception.args)
Luis Hector Chavez9c4a4332017-03-30 13:12:28 -0700100 elif isinstance(unhandled_exception, basestring):
Eric Li861b2d52011-02-04 14:50:35 -0800101 TestError.__init__(self, unhandled_exception)
mblighc2180832008-07-25 03:26:12 +0000102 else:
103 msg = "Unhandled %s: %s"
104 msg %= (unhandled_exception.__class__.__name__,
105 unhandled_exception)
mblighc2180832008-07-25 03:26:12 +0000106 msg += "\n" + traceback.format_exc()
107 TestError.__init__(self, msg)
108
109
110class UnhandledTestFail(TestFail):
111 """Indicates an unhandled fail in a test."""
112 def __init__(self, unhandled_exception):
113 if isinstance(unhandled_exception, TestFail):
114 TestFail.__init__(self, *unhandled_exception.args)
Luis Hector Chavez9c4a4332017-03-30 13:12:28 -0700115 elif isinstance(unhandled_exception, basestring):
Eric Li861b2d52011-02-04 14:50:35 -0800116 TestFail.__init__(self, unhandled_exception)
mblighc2180832008-07-25 03:26:12 +0000117 else:
118 msg = "Unhandled %s: %s"
119 msg %= (unhandled_exception.__class__.__name__,
120 unhandled_exception)
mblighc2180832008-07-25 03:26:12 +0000121 msg += "\n" + traceback.format_exc()
122 TestFail.__init__(self, msg)
123
124
mbligh906b9f72007-11-29 18:56:17 +0000125class CmdError(TestError):
Christopher Wileycd69dc02013-09-09 13:48:58 -0700126 """Indicates that a command failed, is fatal to the test unless caught."""
jadmanski0afbb632008-06-06 21:10:57 +0000127 def __init__(self, command, result_obj, additional_text=None):
128 TestError.__init__(self, command, result_obj, additional_text)
mblighc23051c2008-06-27 19:26:46 +0000129 self.command = command
130 self.result_obj = result_obj
131 self.additional_text = additional_text
mbligh6a2a2df2008-01-16 17:41:55 +0000132
jadmanski0afbb632008-06-06 21:10:57 +0000133 def __str__(self):
jadmanski6ef0b672008-09-30 22:50:19 +0000134 if self.result_obj.exit_status is None:
135 msg = "Command <%s> failed and is not responding to signals"
136 msg %= self.command
137 else:
138 msg = "Command <%s> failed, rc=%d"
139 msg %= (self.command, self.result_obj.exit_status)
140
mblighc23051c2008-06-27 19:26:46 +0000141 if self.additional_text:
142 msg += ", " + self.additional_text
showard6d7e94f2008-08-20 20:53:34 +0000143 msg += '\n' + repr(self.result_obj)
jadmanski0afbb632008-06-06 21:10:57 +0000144 return msg
mbligh906b9f72007-11-29 18:56:17 +0000145
Prathmesh Prabhu54905412017-07-11 17:08:38 -0700146 def __eq__(self, other):
147 if type(self) == type(other):
148 return (self.command == other.command
149 and self.result_obj == other.result_obj
150 and self.additional_text == other.additional_text)
151 else:
152 return NotImplemented
153
mbligh7e1b1502008-06-06 15:05:41 +0000154
Christopher Wileycd69dc02013-09-09 13:48:58 -0700155class CmdTimeoutError(CmdError):
156 """Indicates that a command timed out."""
Christopher Wileycd69dc02013-09-09 13:48:58 -0700157
158
mbligh906b9f72007-11-29 18:56:17 +0000159class PackageError(TestError):
jadmanski0afbb632008-06-06 21:10:57 +0000160 """Indicates an error trying to perform a package operation."""
mbligh906b9f72007-11-29 18:56:17 +0000161
mbligh7e1b1502008-06-06 15:05:41 +0000162
mblighe8673102008-07-16 14:09:03 +0000163class BarrierError(JobError):
164 """Indicates an error happened during a barrier operation."""
mblighe8673102008-07-16 14:09:03 +0000165
166
mbligh999fb132010-04-23 17:22:03 +0000167class BarrierAbortError(BarrierError):
168 """Indicate that the barrier was explicitly aborted by a member."""
mbligh999fb132010-04-23 17:22:03 +0000169
170
mbligh5deff3d2008-01-04 21:21:28 +0000171class InstallError(JobError):
jadmanski0afbb632008-06-06 21:10:57 +0000172 """Indicates an installation error which Terminates and fails the job."""
mbligh03f4fc72007-11-29 20:56:14 +0000173
mbligh7e1b1502008-06-06 15:05:41 +0000174
mbligh6f015c42008-02-12 20:55:03 +0000175class AutotestRunError(AutotestError):
mbligh021679f2008-11-27 00:43:19 +0000176 """Indicates a problem running server side control files."""
mbligh6f015c42008-02-12 20:55:03 +0000177
mbligh7e1b1502008-06-06 15:05:41 +0000178
mbligh6f015c42008-02-12 20:55:03 +0000179class AutotestTimeoutError(AutotestError):
jadmanski0afbb632008-06-06 21:10:57 +0000180 """This exception is raised when an autotest test exceeds the timeout
181 parameter passed to run_timed_test and is killed.
182 """
mbligh6f015c42008-02-12 20:55:03 +0000183
184
Justin Giorgi6ee64532016-08-10 11:32:04 -0700185class GenericHostRunError(Exception):
186 """Indicates a problem in the host run() function running in either client
187 or server code.
188
mblighce955fc2009-08-24 21:59:02 +0000189 Should always be constructed with a tuple of two args (error description
Justin Giorgi6ee64532016-08-10 11:32:04 -0700190 (str), run result object). This is a common class used to create the client
191 and server side versions of it when the distinction is useful.
mblighce955fc2009-08-24 21:59:02 +0000192 """
193 def __init__(self, description, result_obj):
194 self.description = description
195 self.result_obj = result_obj
196 Exception.__init__(self, description, result_obj)
197
198 def __str__(self):
199 return self.description + '\n' + repr(self.result_obj)
200
201
Dale Curtis8adf7892011-09-08 16:13:36 -0700202class HostInstallTimeoutError(JobError):
203 """
204 Indicates the machine failed to be installed after the predetermined
205 timeout.
206 """
Dale Curtis8adf7892011-09-08 16:13:36 -0700207
208
Justin Giorgi6ee64532016-08-10 11:32:04 -0700209class AutotestHostRunError(GenericHostRunError, AutotestError):
mblighce955fc2009-08-24 21:59:02 +0000210 pass
211
212
Prathmesh Prabhudd53f712017-07-11 12:22:06 -0700213class AutotestHostRunCmdError(AutotestHostRunError):
214 """Indicates that the command run via Host.run failed.
215
216 This is equivalent to CmdError when raised from a Host object instead of
217 directly on the DUT using utils.run
218 """
219
220 def __init__(self, command, result_obj, additional_text=''):
221 description = command
222 if additional_text:
223 description += ' (%s)' % additional_text
224 super(AutotestHostRunCmdError, self).__init__(description, result_obj)
225 self.command = command
226 self.additional_text = additional_text
227
228
229class AutotestHostRunTimeoutError(AutotestHostRunCmdError):
230 """Indicates that a command run via Host.run timed out.
231
232 This is equivalent to CmdTimeoutError when raised from a Host object instead
233 of directly on the DUT using utils.run
234 """
235
236
mbligh03f4fc72007-11-29 20:56:14 +0000237# server-specific errors
238
239class AutoservError(Exception):
jadmanski0afbb632008-06-06 21:10:57 +0000240 pass
mbligh03f4fc72007-11-29 20:56:14 +0000241
242
Richard Barnette83e6b542013-12-13 21:38:03 +0000243class AutoservSSHTimeout(AutoservError):
jadmanski0afbb632008-06-06 21:10:57 +0000244 """SSH experienced a connection timeout"""
mbligh34faa282008-01-16 17:44:49 +0000245
246
Justin Giorgi6ee64532016-08-10 11:32:04 -0700247class AutoservRunError(GenericHostRunError, AutoservError):
mblighce955fc2009-08-24 21:59:02 +0000248 pass
showard6d7e94f2008-08-20 20:53:34 +0000249
mbligh03f4fc72007-11-29 20:56:14 +0000250
mbligh9d738d62009-03-09 21:17:10 +0000251class AutoservSshPermissionDeniedError(AutoservRunError):
252 """Indicates that a SSH permission denied error was encountered."""
mbligh9d738d62009-03-09 21:17:10 +0000253
254
mbligh03f4fc72007-11-29 20:56:14 +0000255class AutoservUnsupportedError(AutoservError):
jadmanski0afbb632008-06-06 21:10:57 +0000256 """Error raised when you try to use an unsupported optional feature"""
mbligh03f4fc72007-11-29 20:56:14 +0000257
mbligh7e1b1502008-06-06 15:05:41 +0000258
mbligh03f4fc72007-11-29 20:56:14 +0000259class AutoservHostError(AutoservError):
jadmanski0afbb632008-06-06 21:10:57 +0000260 """Error reaching a host"""
mbligh03f4fc72007-11-29 20:56:14 +0000261
mbligh7e1b1502008-06-06 15:05:41 +0000262
mblighc971c5f2009-06-08 16:48:54 +0000263class AutoservHostIsShuttingDownError(AutoservHostError):
264 """Host is shutting down"""
mblighc971c5f2009-06-08 16:48:54 +0000265
266
267class AutoservNotMountedHostError(AutoservHostError):
268 """Found unmounted partitions that should be mounted"""
mblighc971c5f2009-06-08 16:48:54 +0000269
270
271class AutoservSshPingHostError(AutoservHostError):
272 """SSH ping failed"""
mblighc971c5f2009-06-08 16:48:54 +0000273
274
275class AutoservDiskFullHostError(AutoservHostError):
276 """Not enough free disk space on host"""
mblighc971c5f2009-06-08 16:48:54 +0000277
J. Richard Barnette4164d1d2014-12-02 17:52:33 -0800278 def __init__(self, path, want_gb, free_space_gb):
279 super(AutoservDiskFullHostError, self).__init__(
280 'Not enough free space on %s - %.3fGB free, want %.3fGB' %
281 (path, free_space_gb, want_gb))
mblighc971c5f2009-06-08 16:48:54 +0000282 self.path = path
283 self.want_gb = want_gb
284 self.free_space_gb = free_space_gb
285
286
J. Richard Barnette4164d1d2014-12-02 17:52:33 -0800287class AutoservNoFreeInodesError(AutoservHostError):
288 """Not enough free i-nodes on host"""
289
290 def __init__(self, path, want_inodes, free_inodes):
291 super(AutoservNoFreeInodesError, self).__init__(
292 'Not enough free inodes on %s - %d free, want %d' %
293 (path, free_inodes, want_inodes))
294 self.path = path
295 self.want_inodes = want_inodes
296 self.free_inodes = free_inodes
297
298
mblighc971c5f2009-06-08 16:48:54 +0000299class AutoservHardwareHostError(AutoservHostError):
300 """Found hardware problems with the host"""
mblighc971c5f2009-06-08 16:48:54 +0000301
302
mbligh03f4fc72007-11-29 20:56:14 +0000303class AutoservRebootError(AutoservError):
jadmanski0afbb632008-06-06 21:10:57 +0000304 """Error occured while rebooting a machine"""
mbligh6e2ffec2008-03-05 16:08:34 +0000305
mbligh7e1b1502008-06-06 15:05:41 +0000306
jadmanski65eb8f52009-07-24 18:34:43 +0000307class AutoservShutdownError(AutoservRebootError):
308 """Error occured during shutdown of machine"""
jadmanski65eb8f52009-07-24 18:34:43 +0000309
310
Gwendal Grignou7a61d2f2014-05-23 11:05:51 -0700311class AutoservSuspendError(AutoservRebootError):
312 """Error occured while suspending a machine"""
Gwendal Grignou7a61d2f2014-05-23 11:05:51 -0700313
314
mbligh6e2ffec2008-03-05 16:08:34 +0000315class AutoservSubcommandError(AutoservError):
jadmanski0afbb632008-06-06 21:10:57 +0000316 """Indicates an error while executing a (forked) subcommand"""
317 def __init__(self, func, exit_code):
318 AutoservError.__init__(self, func, exit_code)
319 self.func = func
320 self.exit_code = exit_code
mbligh7e1b1502008-06-06 15:05:41 +0000321
jadmanski0afbb632008-06-06 21:10:57 +0000322 def __str__(self):
323 return ("Subcommand %s failed with exit code %d" %
324 (self.func, self.exit_code))
mbligh91672252008-10-16 22:28:34 +0000325
326
Scott Zawalski62bacae2013-03-05 10:40:32 -0500327class AutoservRepairTotalFailure(AutoservError):
328 """Raised if all attempts to repair the DUT failed."""
Scott Zawalski62bacae2013-03-05 10:40:32 -0500329
330
jadmanskic1dda212009-11-18 19:22:00 +0000331class AutoservInstallError(AutoservError):
332 """Error occured while installing autotest on a host"""
jadmanskic1dda212009-11-18 19:22:00 +0000333
334
Simran Basi31cf2bd2012-08-14 16:51:54 -0700335class AutoservPidAlreadyDeadError(AutoservError):
336 """Error occured by trying to kill a nonexistant PID"""
Simran Basi31cf2bd2012-08-14 16:51:54 -0700337
338
jadmanskic27c2312009-08-05 20:58:51 +0000339# packaging system errors
340
341class PackagingError(AutotestError):
342 'Abstract error class for all packaging related errors.'
343
344
345class PackageUploadError(PackagingError):
346 'Raised when there is an error uploading the package'
347
348
349class PackageFetchError(PackagingError):
350 'Raised when there is an error fetching the package'
351
352
353class PackageRemoveError(PackagingError):
354 'Raised when there is an error removing the package'
355
356
357class PackageInstallError(PackagingError):
358 'Raised when there is an error installing the package'
359
360
361class RepoDiskFullError(PackagingError):
362 'Raised when the destination for packages is full'
363
364
365class RepoWriteError(PackagingError):
366 "Raised when packager cannot write to a repo's desitnation"
367
368
369class RepoUnknownError(PackagingError):
370 "Raised when packager cannot write to a repo's desitnation"
371
372
373class RepoError(PackagingError):
374 "Raised when a repo isn't working in some way"
375
376
Prashanth B6285f6a2014-05-08 18:01:27 -0700377class StageControlFileFailure(Exception):
378 """Exceptions encountered staging control files."""
Prashanth B6285f6a2014-05-08 18:01:27 -0700379
380
Chris Masonef8b53062012-05-08 22:14:18 -0700381class CrosDynamicSuiteException(Exception):
382 """
Chris Masoneb4935552012-08-14 12:05:54 -0700383 Base class for exceptions coming from dynamic suite code in
384 server/cros/dynamic_suite/*.
Chris Masonef8b53062012-05-08 22:14:18 -0700385 """
Chris Masonef8b53062012-05-08 22:14:18 -0700386
387
388class StageBuildFailure(CrosDynamicSuiteException):
389 """Raised when the dev server throws 500 while staging a build."""
Chris Masonef8b53062012-05-08 22:14:18 -0700390
391
392class ControlFileEmpty(CrosDynamicSuiteException):
393 """Raised when the control file exists on the server, but can't be read."""
Chris Masonef8b53062012-05-08 22:14:18 -0700394
395
Alex Millera713e252013-03-01 10:45:44 -0800396class ControlFileMalformed(CrosDynamicSuiteException):
397 """Raised when an invalid control file is read."""
Alex Millera713e252013-03-01 10:45:44 -0800398
399
Chris Masonef8b53062012-05-08 22:14:18 -0700400class AsynchronousBuildFailure(CrosDynamicSuiteException):
401 """Raised when the dev server throws 500 while finishing staging of a build.
402 """
Chris Masonef8b53062012-05-08 22:14:18 -0700403
404
405class SuiteArgumentException(CrosDynamicSuiteException):
406 """Raised when improper arguments are used to run a suite."""
Chris Masonef8b53062012-05-08 22:14:18 -0700407
408
Chris Masone8906ab12012-07-23 15:37:56 -0700409class MalformedDependenciesException(CrosDynamicSuiteException):
410 """Raised when a build has a malformed dependency_info file."""
Chris Masone8906ab12012-07-23 15:37:56 -0700411
412
Chris Masonef8b53062012-05-08 22:14:18 -0700413class InadequateHostsException(CrosDynamicSuiteException):
414 """Raised when there are too few hosts to run a suite."""
Chris Masonef8b53062012-05-08 22:14:18 -0700415
416
417class NoHostsException(CrosDynamicSuiteException):
418 """Raised when there are no healthy hosts to run a suite."""
Chris Masonef8b53062012-05-08 22:14:18 -0700419
420
421class ControlFileNotFound(CrosDynamicSuiteException):
422 """Raised when a control file cannot be found and/or read."""
Chris Masonef8b53062012-05-08 22:14:18 -0700423
424
425class NoControlFileList(CrosDynamicSuiteException):
Chris Masone9807bd62012-07-11 14:44:17 -0700426 """Raised to indicate that a listing can't be done."""
Chris Masone9807bd62012-07-11 14:44:17 -0700427
428
xixuan0f7755d2016-04-18 14:49:12 -0700429class SuiteControlFileException(CrosDynamicSuiteException):
430 """Raised when failing to list the contents of all control file."""
xixuan0f7755d2016-04-18 14:49:12 -0700431
432
Chris Masone9807bd62012-07-11 14:44:17 -0700433class HostLockManagerReuse(CrosDynamicSuiteException):
434 """Raised when a caller tries to re-use a HostLockManager instance."""
Chris Masonef8b53062012-05-08 22:14:18 -0700435
436
Simran Basi94d9bd02012-11-12 15:13:59 -0800437class ReimageAbortedException(CrosDynamicSuiteException):
438 """Raised when a Reimage job is aborted"""
Simran Basi94d9bd02012-11-12 15:13:59 -0800439
440
Alex Miller30837902013-02-02 15:52:43 -0800441class UnknownReimageType(CrosDynamicSuiteException):
442 """Raised when a suite passes in an invalid reimage type"""
Alex Miller30837902013-02-02 15:52:43 -0800443
444
Alex Miller24c27c12012-08-09 10:24:24 -0700445class NoUniquePackageFound(Exception):
446 """Raised when an executable cannot be mapped back to a single package."""
Alex Miller24c27c12012-08-09 10:24:24 -0700447
448
Alex Miller4a193692013-08-21 13:59:01 -0700449class RPCException(Exception):
450 """Raised when an RPC encounters an error that a client might wish to
451 handle specially."""
Alex Miller4a193692013-08-21 13:59:01 -0700452
453
454class NoEligibleHostException(RPCException):
455 """Raised when no host could satisfy the requirements of a job."""
Alex Miller4a193692013-08-21 13:59:01 -0700456
457
Xixuan Wu76cd0582017-12-21 13:23:28 -0800458class UnmodifiableLabelException(RPCException):
459 """Raised when an RPC tries to modify static labels."""
460
461
Aviv Keshet46250752013-08-27 15:52:06 -0700462class InvalidBgJobCall(Exception):
463 """Raised when an invalid call is made to a BgJob object."""
Aviv Keshet46250752013-08-27 15:52:06 -0700464
465
Jakob Juelich3b27dbc2014-09-03 18:05:37 -0700466class HeartbeatOnlyAllowedInShardModeException(Exception):
467 """Raised when a heartbeat is attempted but not allowed."""
Jakob Juelich3b27dbc2014-09-03 18:05:37 -0700468
469
Jakob Juelicha94efe62014-09-18 16:02:49 -0700470class UnallowedRecordsSentToMaster(Exception):
Aviv Keshet6dec0e12017-04-17 15:23:33 -0700471 """Raised when an illegal record was sent from shard to master."""
472
473
474class IgnorableUnallowedRecordsSentToMaster(UnallowedRecordsSentToMaster):
475 """Raised when non-fatal illegal record was sent from shard.
476
477 This exception may be raised by rpc model logic on master, but will
478 not be returned back to heartbeat client. It indicates that some records
479 may have been illegal, but the master is ignoring those records and
480 proceeding with the rest of the heartbeat handling.
481 """
Jakob Juelicha94efe62014-09-18 16:02:49 -0700482
483
Dan Shi9a535c92014-11-24 08:52:40 -0800484class InvalidDataError(Exception):
Aviv Keshet6dec0e12017-04-17 15:23:33 -0700485 """Exception raised when invalid data provided for database operation."""
Dan Shi9a535c92014-11-24 08:52:40 -0800486
487
Dan Shi767dced2015-02-01 00:21:07 -0800488class ContainerError(Exception):
Aviv Keshet6dec0e12017-04-17 15:23:33 -0700489 """Exception raised when program runs into error using container."""
Dan Shi767dced2015-02-01 00:21:07 -0800490
491
Simran Basi9f364a62015-12-07 14:15:19 -0800492class IllegalUser(Exception):
493 """Exception raise when a program runs as an illegal user."""
494
495
Keith Haddow07f1d3e2017-08-03 17:40:41 -0700496class AutoservDirectoryNotFoundError(AutoservHostError):
497 """Exception raised when an expected directory is not found."""
498
499
500class AutoservDiskSizeUnknownError(AutoservHostError):
501 """Exception raised when the disk space could not be determined."""
502
503
mbligh91672252008-10-16 22:28:34 +0000504# This MUST remain at the end of the file.
505# Limit 'from error import *' to only import the exception instances.
506for _name, _thing in locals().items():
507 try:
508 if issubclass(_thing, Exception):
509 __all__.append(_name)
510 except TypeError:
511 pass # _thing not a class
512__all__ = tuple(__all__)