blob: 43d3111a74c7c7ba41995d0f3c34a852d9c5c74f [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
Kuang-che Wu944fda42019-12-12 20:31:29 +080078 def __init__(self, rev, bad_times=1, term_old='OLD', term_new='NEW'):
79 super(VerifyOldBehaviorFailed, self).__init__(rev, term_old, term_new,
80 bad_times)
Kuang-che Wue121fae2018-11-09 16:18:39 +080081
82
Kuang-che Wu1dc5bd72019-01-19 00:14:46 +080083class VerifyNewBehaviorFailed(VerificationFailed):
Kuang-che Wue121fae2018-11-09 16:18:39 +080084 """New version does not behave as new."""
85
Kuang-che Wu944fda42019-12-12 20:31:29 +080086 def __init__(self, rev, bad_times=1, term_old='OLD', term_new='NEW'):
87 super(VerifyNewBehaviorFailed, self).__init__(rev, term_new, term_old,
88 bad_times)
Kuang-che Wue121fae2018-11-09 16:18:39 +080089
90
91class UnableToProceed(Exception):
92 """Unable to narrow bisect range further due to too many errors."""
93
94
95class InternalError(Exception):
96 """bisect-kit internal error.
97
98 In general, it means something wrong or not implemented in bisect-kit and
99 needs fix.
100 """
101
102
103class ExternalError(Exception):
Kuang-che Wu8b654092018-11-09 17:56:25 +0800104 """Errors in external dependency.
Kuang-che Wue121fae2018-11-09 16:18:39 +0800105
106 Like configuration errors, network errors, DUT issues, etc.
107 """
Kuang-che Wu44278142019-03-04 11:33:57 +0800108
109
110class SshConnectionError(Exception):
111 """SSH connection error."""