blob: 4cde7fac6ad0f8e223d213034cd6cc97e98ec54d [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
Kuang-che Wu0c9b7942019-10-30 16:55:39 +080033class DutLeaseException(Exception):
34 """Issues of skylab DUT lease."""
35
36
Kuang-che Wue121fae2018-11-09 16:18:39 +080037class WrongAssumption(Exception):
38 """Wrong assumption.
39
40 For non-noisy binary search, the assumption is all versions with old behavior
41 occurs before all versions with new behavior. But the eval result contracted
42 this ordering assumption.
43
44 p.s. This only happens (could be detected) if users marked versions 'old' and
45 'new' manually.
46
47 Suggestion: try noisy search instead (--noisy).
48 """
49
50
Kuang-che Wuec566f32019-03-07 16:53:32 +080051class DiagnoseContradiction(Exception):
52 """Contradiction happened during diagnose.
53
54 Test result of individual component/version is unreliable/untrustable
55 (something wrong and/or flakiness out of control).
56 """
57
58
Kuang-che Wue121fae2018-11-09 16:18:39 +080059class VerificationFailed(Exception):
60 """Bisection range is verified false."""
61
62 def __init__(self, rev, expect, actual, bad_times=1):
63 self.rev = rev
64 self.expect = expect
65 self.actual = actual
66 self.bad_times = bad_times
67
68 msg = 'rev=%s expect "%s" but got "%s"' % (self.rev, self.expect,
69 self.actual)
70 if self.bad_times > 1:
71 msg += ' %d times' % self.bad_times
72 super(VerificationFailed, self).__init__(msg)
73
74
Kuang-che Wu1dc5bd72019-01-19 00:14:46 +080075class VerifyOldBehaviorFailed(VerificationFailed):
Kuang-che Wue121fae2018-11-09 16:18:39 +080076 """Old version does not behave as old."""
77
78 def __init__(self, rev, bad_times=1):
Kuang-che Wu1dc5bd72019-01-19 00:14:46 +080079 super(VerifyOldBehaviorFailed, self).__init__(rev, 'old', 'new', bad_times)
Kuang-che Wue121fae2018-11-09 16:18:39 +080080
81
Kuang-che Wu1dc5bd72019-01-19 00:14:46 +080082class VerifyNewBehaviorFailed(VerificationFailed):
Kuang-che Wue121fae2018-11-09 16:18:39 +080083 """New version does not behave as new."""
84
85 def __init__(self, rev, bad_times=1):
Kuang-che Wu1dc5bd72019-01-19 00:14:46 +080086 super(VerifyNewBehaviorFailed, self).__init__(rev, 'new', 'old', bad_times)
Kuang-che Wue121fae2018-11-09 16:18:39 +080087
88
89class UnableToProceed(Exception):
90 """Unable to narrow bisect range further due to too many errors."""
91
92
93class InternalError(Exception):
94 """bisect-kit internal error.
95
96 In general, it means something wrong or not implemented in bisect-kit and
97 needs fix.
98 """
99
100
101class ExternalError(Exception):
Kuang-che Wu8b654092018-11-09 17:56:25 +0800102 """Errors in external dependency.
Kuang-che Wue121fae2018-11-09 16:18:39 +0800103
104 Like configuration errors, network errors, DUT issues, etc.
105 """
Kuang-che Wu44278142019-03-04 11:33:57 +0800106
107
108class SshConnectionError(Exception):
109 """SSH connection error."""