Skip to content

Commit c629405

Browse files
committed
Raise OverkizError instead of ValueError for API data issues
DeviceIdentifier.from_device_url() and Device validation now raise OverkizError, consistent with the rest of the exception hierarchy. ValueError is reserved for programming errors (wrong argument types).
1 parent ba18a7f commit c629405

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

pyoverkiz/models.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from pyoverkiz.enums.command import OverkizCommand
2828
from pyoverkiz.enums.protocol import Protocol
2929
from pyoverkiz.enums.server import APIType, Server
30+
from pyoverkiz.exceptions import OverkizError
3031
from pyoverkiz.obfuscate import obfuscate_email, obfuscate_id, obfuscate_string
3132
from pyoverkiz.types import DATA_TYPE_TO_PYTHON, CommandParameterValue, StateType
3233

@@ -363,7 +364,7 @@ def from_device_url(cls, device_url: str) -> DeviceIdentifier:
363364
"""Parse a device URL into its structured identifier components."""
364365
match = DEVICE_URL_RE.fullmatch(device_url)
365366
if not match:
366-
raise ValueError(f"Invalid device URL: {device_url}")
367+
raise OverkizError(f"Invalid device URL: {device_url}")
367368

368369
subsystem_id = (
369370
int(match.group("subsystemId")) if match.group("subsystemId") else None
@@ -414,7 +415,9 @@ def __attrs_post_init__(self) -> None:
414415
self.widget = UIWidget(self.definition.widget_name)
415416

416417
if self.ui_class is None or self.widget is None:
417-
raise ValueError(f"Device {self.device_url} is missing ui_class or widget")
418+
raise OverkizError(
419+
f"Device {self.device_url} is missing ui_class or widget"
420+
)
418421

419422
def supports_command(self, command: str | OverkizCommand) -> bool:
420423
"""Check if device supports a command."""

0 commit comments

Comments
 (0)