This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
devicehub-teal/ereuse_devicehub/resources/device/exceptions.py

31 lines
940 B
Python
Raw Permalink Normal View History

2023-03-21 11:08:13 +00:00
from ereuse_devicehub.teal.marshmallow import ValidationError
2018-04-27 17:16:43 +00:00
class MismatchBetweenIds(ValidationError):
def __init__(self, other_device_id: int, field: str, value: str):
2023-03-21 11:08:13 +00:00
message = 'The device {} has the same {} than this one ({}).'.format(
other_device_id, field, value
)
2018-04-27 17:16:43 +00:00
super().__init__(message, field_names=[field])
class NeedsId(ValidationError):
def __init__(self):
message = 'We couldn\'t get an ID for this device. Is this a custom PC?'
super().__init__(message)
class DeviceIsInAnotherDevicehub(ValidationError):
2023-03-21 11:08:13 +00:00
def __init__(
self,
tag_id,
message=None,
field_names=None,
fields=None,
data=None,
valid_data=None,
**kwargs,
):
message = message or 'Device {} is from another Devicehub.'.format(tag_id)
super().__init__(message, field_names, fields, data, valid_data, **kwargs)