| 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 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 | 119 |
| 120 class UnknownModificationTypeError(MonitoringError): | 120 class UnknownModificationTypeError(MonitoringError): |
| 121 """Raised when using a Modification with an unknown type value.""" | 121 """Raised when using a Modification with an unknown type value.""" |
| 122 | 122 |
| 123 def __init__(self, mod_type): | 123 def __init__(self, mod_type): |
| 124 self.mod_type = mod_type | 124 self.mod_type = mod_type |
| 125 | 125 |
| 126 def __str__(self): | 126 def __str__(self): |
| 127 return 'Unknown modification type "%s"' % self.mod_type | 127 return 'Unknown modification type "%s"' % self.mod_type |
| 128 |
| 129 |
| 130 class MetricDefinitionError(MonitoringError): |
| 131 """Raised when a metric was defined incorrectly.""" |
| 132 |
| 133 |
| 134 class WrongFieldsError(MonitoringError): |
| 135 """Raised when a metric is given different fields to its definition.""" |
| 136 |
| 137 def __init__(self, metric_name, got, expected): |
| 138 self.metric_name = metric_name |
| 139 self.got = got |
| 140 self.expected = expected |
| 141 |
| 142 def __str__(self): |
| 143 return 'Metric "%s" is defined with %s fields but was given %s' % ( |
| 144 self.metric_name, self.expected, self.got) |
| OLD | NEW |