# -*- coding: utf-8 -*- # !/usr/bin/env python from apps.web.exceptions import UserServerException class ParameterError(UserServerException): pass class DeviceNetworkTimeoutError(Exception): pass class UartTimeoutError(Exception): pass class NotConnectError(Exception): pass class StartDeviceError(Exception): def __init__(self, device_rst = None): self.device_rst = device_rst super(StartDeviceError, self).__init__() def __str__(self): if self.device_rst: return u'启动设备失败({}),您支付的金币已经退还到您的账户。'.format(self.device_rst) else: return u'启动设备失败,您支付的金币已经退还到您的账户。' def __repr__(self): return 'main board error<{}>'.format(self.device_rst) class MessageSenderException(Exception): def __init__(self, exception): self.exception = exception super(MessageSenderException, self).__init__() def __repr__(self): return 'message sender error<{}>'.format(self.exception) class MqttConnectError(Exception): pass class MqttSubscribeError(Exception): pass class MqttPublishError(Exception): pass class StartDeviceCommuationException(Exception): def __init__(self, rst): self.rst = rst super(StartDeviceCommuationException, self).__init__() def __str__(self): return u'启动设备失败({}),您支付的金币已经退还到您的账户。'.format(self.rst) def __repr__(self): return 'module error<{}>'.format(self.rst) class ReportProxyError(Exception): pass class ReportProxyTypeError(Exception): pass class ReportProxyValueError(Exception): pass class ServiceException(UserServerException): _default_result = {"result": 2, "description": u"使用故障"} def __init__(self, result = None): self.result = result or self._default_result super(ServiceException, self).__init__() def __str__(self): return repr(self.result) class ClientServiceTimeOutException(ServiceException): _default_result = {"result": 2, "description": u"此设备网络超时,请您稍后再试,或更换机器重新扫码,谢谢!"} class ClientServiceSerialException(ServiceException): _default_result = {"result": 2, "description": u"此设备正忙,请更换机器重新扫码,谢谢!"} class ManagerServiceTimeOutException(ServiceException): _default_result = {"result": 2, "description": u"此设备离线,请稍后再试,或将天线置于机器外部,重新上电试试!"} class ManagerServiceSerialException(ServiceException): _default_result = {"result": 2, "description": u"此设备串口故障,请调整设备串口线重新上电试试!"} class DeviceNotExistException(UserServerException): def __init__(self): super(DeviceNotExistException, self).__init__() def __str__(self): return repr(u'设备不存在') class InvalidFileSize(UserServerException): def __init__(self, message, limit): super(InvalidFileSize, self).__init__(message) self.limit = limit class InvalidFileName(UserServerException): pass class InvalidPermission(UserServerException): pass class InvalidChildClass(UserServerException): pass class InvalidParameter(UserServerException): pass class ImproperlyConfigured(UserServerException): pass class FormatError(UserServerException): pass class EmptyInput(UserServerException): pass class UpdateError(UserServerException): """当模型更新失败的时候抛出""" pass class InsufficientFundsError(Exception): pass class TestError(UserServerException): _default_result = {"description": u"测试故障"} def __init__(self, result = None): self._result = result or self._default_result super(TestError, self).__init__() def __str__(self): return self._result.get("description", "") class TestTimeOutError(TestError): _default_result = {"description": u"测试串口超时故障"} class TestSerialError(TestError): _default_result = {"description": u"测试串口通信故障"} class MerchantError(Exception): pass class JOSError(Exception): pass class RentDeviceError(Exception): pass class NoDeviceFound(UserServerException): def __init__(self, dev_no): self.dev_no = dev_no def __repr__(self): return 'device({}) not found'.format(self.dev_no) def __str__(self): return repr(self) class NoGroupFound(UserServerException): def __init__(self, group_id): self.group_id = group_id def __repr__(self): return 'group({}) not found'.format(self.group_id) def __str__(self): return repr(self) class NoAgentFound(UserServerException): def __init__(self, agent_id): self.agent_id = agent_id def __repr__(self): return 'agent(id={}) not found'.format(self.agent_id) def __str__(self): return repr(self) class NoManagerFound(UserServerException): def __init__(self, manager_id): self.manager_id = manager_id def __repr__(self): return 'manager(id={}) not found'.format(self.manager_id) def __str__(self): return repr(self) class ImproperlyOperatedBalance(UserServerException): pass class WithdrawError(UserServerException): pass class OrderCheckError(UserServerException): pass class InterceptException(UserServerException): def __init__(self, redirect): self.redirect = redirect