| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 """Raised when some error is encountered in flushing specific metrics.""" | 110 """Raised when some error is encountered in flushing specific metrics.""" |
| 111 | 111 |
| 112 def __init__(self, error_count): | 112 def __init__(self, error_count): |
| 113 self.error_count = error_count | 113 self.error_count = error_count |
| 114 | 114 |
| 115 def __str__(self): | 115 def __str__(self): |
| 116 return ('Failed to flush %d metrics. See tracebacks above' % | 116 return ('Failed to flush %d metrics. See tracebacks above' % |
| 117 (self.error_count)) | 117 (self.error_count)) |
| 118 | 118 |
| 119 | 119 |
| 120 class UnknownModificationTypeError(MonitoringError): | |
| 121 """Raised when using a Modification with an unknown type value.""" | |
| 122 | |
| 123 def __init__(self, mod_type): | |
| 124 self.mod_type = mod_type | |
| 125 | |
| 126 def __str__(self): | |
| 127 return 'Unknown modification type "%s"' % self.mod_type | |
| 128 | |
| 129 | |
| 130 class MetricDefinitionError(MonitoringError): | 120 class MetricDefinitionError(MonitoringError): |
| 131 """Raised when a metric was defined incorrectly.""" | 121 """Raised when a metric was defined incorrectly.""" |
| 132 | 122 |
| 133 | 123 |
| 134 class WrongFieldsError(MonitoringError): | 124 class WrongFieldsError(MonitoringError): |
| 135 """Raised when a metric is given different fields to its definition.""" | 125 """Raised when a metric is given different fields to its definition.""" |
| 136 | 126 |
| 137 def __init__(self, metric_name, got, expected): | 127 def __init__(self, metric_name, got, expected): |
| 138 self.metric_name = metric_name | 128 self.metric_name = metric_name |
| 139 self.got = got | 129 self.got = got |
| 140 self.expected = expected | 130 self.expected = expected |
| 141 | 131 |
| 142 def __str__(self): | 132 def __str__(self): |
| 143 return 'Metric "%s" is defined with %s fields but was given %s' % ( | 133 return 'Metric "%s" is defined with %s fields but was given %s' % ( |
| 144 self.metric_name, self.expected, self.got) | 134 self.metric_name, self.expected, self.got) |
| OLD | NEW |