OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Classes representing errors that can be raised by the monitoring library.""" | 5 """Classes representing errors that can be raised by the monitoring library.""" |
6 | 6 |
7 | 7 |
8 class MonitoringError(Exception): | 8 class MonitoringError(Exception): |
9 """Base class for exceptions raised by this module.""" | 9 """Base class for exceptions raised by this module.""" |
10 | 10 |
11 | 11 |
12 class MonitoringDecreasingValueError(MonitoringError): | 12 class MonitoringDecreasingValueError(MonitoringError): |
13 """Raised when setting a metric value that should increase but doesn't.""" | 13 """Raised when setting a metric value that should increase but doesn't.""" |
14 | 14 |
15 def __init__(self, metric, old_value, new_value): | 15 def __init__(self, metric, old_value, new_value): |
16 self.metric = metric, | 16 self.metric = metric |
17 self.old_value = old_value | 17 self.old_value = old_value |
18 self.new_value = new_value | 18 self.new_value = new_value |
19 | 19 |
20 def __str__(self): | 20 def __str__(self): |
21 return ('Monotonically increasing metric "%s" was given value "%s", which ' | 21 return ('Monotonically increasing metric "%s" was given value "%s", which ' |
22 'is not greater than or equal to "%s".' % ( | 22 'is not greater than or equal to "%s".' % ( |
23 self.metric, self.new_value, self.old_value)) | 23 self.metric, self.new_value, self.old_value)) |
24 | 24 |
25 | 25 |
26 class MonitoringDuplicateRegistrationError(MonitoringError): | 26 class MonitoringDuplicateRegistrationError(MonitoringError): |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 | 108 |
109 class UnknownModificationTypeError(MonitoringError): | 109 class UnknownModificationTypeError(MonitoringError): |
110 """Raised when using a Modification with an unknown type value.""" | 110 """Raised when using a Modification with an unknown type value.""" |
111 | 111 |
112 def __init__(self, mod_type): | 112 def __init__(self, mod_type): |
113 self.mod_type = mod_type | 113 self.mod_type = mod_type |
114 | 114 |
115 def __str__(self): | 115 def __str__(self): |
116 return 'Unknown modification type "%s"' % self.mod_type | 116 return 'Unknown modification type "%s"' % self.mod_type |
OLD | NEW |