|
11 | 11 |
|
12 | 12 | from frequenz.core.enum import Enum, deprecated_member, unique |
13 | 13 |
|
14 | | -from .._exception import UnrecognizedValueError, UnspecifiedValueError |
| 14 | +from .._exception import UnrecognizedEnumValueError, UnspecifiedEnumValueError |
15 | 15 | from ._bounds import Bounds |
16 | 16 | from ._metric import Metric |
17 | 17 |
|
@@ -147,21 +147,23 @@ def get_category(self) -> MetricConnectionCategory: |
147 | 147 | The category when it is a known `MetricConnectionCategory` member. |
148 | 148 |
|
149 | 149 | Raises: |
150 | | - UnspecifiedValueError: If the category is unspecified (the raw value |
151 | | - `0` or a member whose value is `0`). |
152 | | - UnrecognizedValueError: If the category is an `int` this client does |
153 | | - not recognize. The raw value is available on the error's `value` |
154 | | - attribute. |
| 150 | + UnspecifiedEnumValueError: If the category is unspecified (the raw |
| 151 | + value `0` or a member whose value is `0`). |
| 152 | + UnrecognizedEnumValueError: If the category is an `int` this |
| 153 | + client does not recognize. The raw value is available on the |
| 154 | + error's `value` attribute. |
155 | 155 | """ |
156 | 156 | with warnings.catch_warnings(): |
157 | 157 | warnings.filterwarnings("ignore", category=DeprecationWarning) |
158 | 158 | match self.category: |
159 | 159 | case 0 | MetricConnectionCategory.UNSPECIFIED: |
160 | | - raise UnspecifiedValueError("connection category is unspecified") |
| 160 | + raise UnspecifiedEnumValueError( |
| 161 | + "connection category is unspecified" |
| 162 | + ) |
161 | 163 | case MetricConnectionCategory(): |
162 | 164 | return self.category |
163 | 165 | case int(): |
164 | | - raise UnrecognizedValueError( |
| 166 | + raise UnrecognizedEnumValueError( |
165 | 167 | self.category, |
166 | 168 | f"connection category {self.category!r} is not a recognized " |
167 | 169 | "MetricConnectionCategory", |
@@ -293,21 +295,21 @@ def get_metric(self) -> Metric: |
293 | 295 | The metric when it is a known `Metric` member. |
294 | 296 |
|
295 | 297 | Raises: |
296 | | - UnspecifiedValueError: If the metric is unspecified (the raw value |
297 | | - `0` or a member whose value is `0`). |
298 | | - UnrecognizedValueError: If the metric is an `int` this client does |
299 | | - not recognize. The raw value is available on the error's `value` |
300 | | - attribute. |
| 298 | + UnspecifiedEnumValueError: If the metric is unspecified (the raw |
| 299 | + value `0` or a member whose value is `0`). |
| 300 | + UnrecognizedEnumValueError: If the metric is an `int` this client |
| 301 | + does not recognize. The raw value is available on the error's |
| 302 | + `value` attribute. |
301 | 303 | """ |
302 | 304 | with warnings.catch_warnings(): |
303 | 305 | warnings.filterwarnings("ignore", category=DeprecationWarning) |
304 | 306 | match self.metric: |
305 | 307 | case 0 | Metric.UNSPECIFIED: |
306 | | - raise UnspecifiedValueError("sampled metric is unspecified") |
| 308 | + raise UnspecifiedEnumValueError("sampled metric is unspecified") |
307 | 309 | case Metric(): |
308 | 310 | return self.metric |
309 | 311 | case int(): |
310 | | - raise UnrecognizedValueError( |
| 312 | + raise UnrecognizedEnumValueError( |
311 | 313 | self.metric, |
312 | 314 | f"sampled metric {self.metric!r} is not a recognized Metric", |
313 | 315 | ) |
|
0 commit comments