blob: 242b619c5ad655797b453ef3f73165c122b64d51 [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
Kuang-che Wu6d91b8c2020-11-24 20:14:35 +080014 super().__init__(str(self))
Kuang-che Wue121fae2018-11-09 16:18:39 +080015
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
Kuang-che Wu6d91b8c2020-11-24 20:14:35 +080076 super().__init__(msg)
Kuang-che Wue121fae2018-11-09 16:18:39 +080077
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'):
Kuang-che Wu6d91b8c2020-11-24 20:14:35 +080083 super().__init__(rev, term_old, term_new, bad_times)
Kuang-che Wue121fae2018-11-09 16:18:39 +080084
85
Kuang-che Wu1dc5bd72019-01-19 00:14:46 +080086class VerifyNewBehaviorFailed(VerificationFailed):
Kuang-che Wue121fae2018-11-09 16:18:39 +080087 """New version does not behave as new."""
88
Kuang-che Wu944fda42019-12-12 20:31:29 +080089 def __init__(self, rev, bad_times=1, term_old='OLD', term_new='NEW'):
Kuang-che Wu6d91b8c2020-11-24 20:14:35 +080090 super().__init__(rev, term_new, term_old, bad_times)
Kuang-che Wue121fae2018-11-09 16:18:39 +080091
92
93class UnableToProceed(Exception):
94 """Unable to narrow bisect range further due to too many errors."""
95
96
97class InternalError(Exception):
98 """bisect-kit internal error.
99
100 In general, it means something wrong or not implemented in bisect-kit and
101 needs fix.
102 """
103
104
105class ExternalError(Exception):
Kuang-che Wu8b654092018-11-09 17:56:25 +0800106 """Errors in external dependency.
Kuang-che Wue121fae2018-11-09 16:18:39 +0800107
108 Like configuration errors, network errors, DUT issues, etc.
109 """
Kuang-che Wu44278142019-03-04 11:33:57 +0800110
111
112class SshConnectionError(Exception):
113 """SSH connection error."""