blob: 893bb6e7bf7825c344a22ec226a8c607ff5a0aa1 [file] [log] [blame]
Kuang-che Wue121fae2018-11-09 16:18:39 +08001# -*- coding: utf-8 -*-
2# Copyright 2018 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""Exception classes."""
6
7
8class ArgumentError(Exception):
9 """Bad command line argument."""
10
11 def __init__(self, argument_name, message):
12 self.argument_name = argument_name
13 self.message = message
14 super(ArgumentError, self).__init__(str(self))
15
16 def __str__(self):
17 if self.argument_name:
18 return 'argument %s: %s' % (self.argument_name, self.message)
19 return self.message
20
21
Kuang-che Wu96e42762020-07-01 16:38:37 +080022class Uninitialized(Exception):
23 """'init' must succeed before other subcommands."""
24
25
Kuang-che Wue121fae2018-11-09 16:18:39 +080026class ExecutionFatalError(Exception):
27 """Fatal error and bisect should not continue.
28
29 Switch or eval commands return fatal exit code.
30 """
31
32
33class NoDutAvailable(Exception):
34 """Unable to allocate DUT from lab."""
35
36
Kuang-che Wu0c9b7942019-10-30 16:55:39 +080037class DutLeaseException(Exception):
38 """Issues of skylab DUT lease."""
39
40
Kuang-che Wue121fae2018-11-09 16:18:39 +080041class WrongAssumption(Exception):
42 """Wrong assumption.
43
44 For non-noisy binary search, the assumption is all versions with old behavior
45 occurs before all versions with new behavior. But the eval result contracted
46 this ordering assumption.
47
48 p.s. This only happens (could be detected) if users marked versions 'old' and
49 'new' manually.
50
51 Suggestion: try noisy search instead (--noisy).
52 """
53
54
Kuang-che Wuec566f32019-03-07 16:53:32 +080055class DiagnoseContradiction(Exception):
56 """Contradiction happened during diagnose.
57
58 Test result of individual component/version is unreliable/untrustable
59 (something wrong and/or flakiness out of control).
60 """
61
62
Kuang-che Wue121fae2018-11-09 16:18:39 +080063class VerificationFailed(Exception):
64 """Bisection range is verified false."""
65
66 def __init__(self, rev, expect, actual, bad_times=1):
67 self.rev = rev
68 self.expect = expect
69 self.actual = actual
70 self.bad_times = bad_times
71
72 msg = 'rev=%s expect "%s" but got "%s"' % (self.rev, self.expect,
73 self.actual)
74 if self.bad_times > 1:
75 msg += ' %d times' % self.bad_times
76 super(VerificationFailed, self).__init__(msg)
77
78
Kuang-che Wu1dc5bd72019-01-19 00:14:46 +080079class VerifyOldBehaviorFailed(VerificationFailed):
Kuang-che Wue121fae2018-11-09 16:18:39 +080080 """Old version does not behave as old."""
81
Kuang-che Wu944fda42019-12-12 20:31:29 +080082 def __init__(self, rev, bad_times=1, term_old='OLD', term_new='NEW'):
83 super(VerifyOldBehaviorFailed, self).__init__(rev, term_old, term_new,
84 bad_times)
Kuang-che Wue121fae2018-11-09 16:18:39 +080085
86
Kuang-che Wu1dc5bd72019-01-19 00:14:46 +080087class VerifyNewBehaviorFailed(VerificationFailed):
Kuang-che Wue121fae2018-11-09 16:18:39 +080088 """New version does not behave as new."""
89
Kuang-che Wu944fda42019-12-12 20:31:29 +080090 def __init__(self, rev, bad_times=1, term_old='OLD', term_new='NEW'):
91 super(VerifyNewBehaviorFailed, self).__init__(rev, term_new, term_old,
92 bad_times)
Kuang-che Wue121fae2018-11-09 16:18:39 +080093
94
95class UnableToProceed(Exception):
96 """Unable to narrow bisect range further due to too many errors."""
97
98
99class InternalError(Exception):
100 """bisect-kit internal error.
101
102 In general, it means something wrong or not implemented in bisect-kit and
103 needs fix.
104 """
105
106
107class ExternalError(Exception):
Kuang-che Wu8b654092018-11-09 17:56:25 +0800108 """Errors in external dependency.
Kuang-che Wue121fae2018-11-09 16:18:39 +0800109
110 Like configuration errors, network errors, DUT issues, etc.
111 """
Kuang-che Wu44278142019-03-04 11:33:57 +0800112
113
114class SshConnectionError(Exception):
115 """SSH connection error."""