blob: a8fc66c51c66818304644b2686956fe30446c9c4 [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
22class ExecutionFatalError(Exception):
23 """Fatal error and bisect should not continue.
24
25 Switch or eval commands return fatal exit code.
26 """
27
28
29class NoDutAvailable(Exception):
30 """Unable to allocate DUT from lab."""
31
32
33class WrongAssumption(Exception):
34 """Wrong assumption.
35
36 For non-noisy binary search, the assumption is all versions with old behavior
37 occurs before all versions with new behavior. But the eval result contracted
38 this ordering assumption.
39
40 p.s. This only happens (could be detected) if users marked versions 'old' and
41 'new' manually.
42
43 Suggestion: try noisy search instead (--noisy).
44 """
45
46
Kuang-che Wuec566f32019-03-07 16:53:32 +080047class DiagnoseContradiction(Exception):
48 """Contradiction happened during diagnose.
49
50 Test result of individual component/version is unreliable/untrustable
51 (something wrong and/or flakiness out of control).
52 """
53
54
Kuang-che Wue121fae2018-11-09 16:18:39 +080055class VerificationFailed(Exception):
56 """Bisection range is verified false."""
57
58 def __init__(self, rev, expect, actual, bad_times=1):
59 self.rev = rev
60 self.expect = expect
61 self.actual = actual
62 self.bad_times = bad_times
63
64 msg = 'rev=%s expect "%s" but got "%s"' % (self.rev, self.expect,
65 self.actual)
66 if self.bad_times > 1:
67 msg += ' %d times' % self.bad_times
68 super(VerificationFailed, self).__init__(msg)
69
70
Kuang-che Wu1dc5bd72019-01-19 00:14:46 +080071class VerifyOldBehaviorFailed(VerificationFailed):
Kuang-che Wue121fae2018-11-09 16:18:39 +080072 """Old version does not behave as old."""
73
74 def __init__(self, rev, bad_times=1):
Kuang-che Wu1dc5bd72019-01-19 00:14:46 +080075 super(VerifyOldBehaviorFailed, self).__init__(rev, 'old', 'new', bad_times)
Kuang-che Wue121fae2018-11-09 16:18:39 +080076
77
Kuang-che Wu1dc5bd72019-01-19 00:14:46 +080078class VerifyNewBehaviorFailed(VerificationFailed):
Kuang-che Wue121fae2018-11-09 16:18:39 +080079 """New version does not behave as new."""
80
81 def __init__(self, rev, bad_times=1):
Kuang-che Wu1dc5bd72019-01-19 00:14:46 +080082 super(VerifyNewBehaviorFailed, self).__init__(rev, 'new', 'old', bad_times)
Kuang-che Wue121fae2018-11-09 16:18:39 +080083
84
85class UnableToProceed(Exception):
86 """Unable to narrow bisect range further due to too many errors."""
87
88
89class InternalError(Exception):
90 """bisect-kit internal error.
91
92 In general, it means something wrong or not implemented in bisect-kit and
93 needs fix.
94 """
95
96
97class ExternalError(Exception):
Kuang-che Wu8b654092018-11-09 17:56:25 +080098 """Errors in external dependency.
Kuang-che Wue121fae2018-11-09 16:18:39 +080099
100 Like configuration errors, network errors, DUT issues, etc.
101 """
Kuang-che Wu44278142019-03-04 11:33:57 +0800102
103
104class SshConnectionError(Exception):
105 """SSH connection error."""