Source code for airtest.core.error

# -*- coding: utf-8 -*-

"""
error classes
"""

[docs]class BaseError(Exception): def __init__(self, value): self.value = value def __str__(self): return repr(self.value)
[docs]class AirtestError(BaseError): """ This is Airtest BaseError """ pass
[docs]class InvalidMatchingMethodError(BaseError): """ This is InvalidMatchingMethodError BaseError When an invalid matching method is used in settings. """ pass
[docs]class TargetNotFoundError(AirtestError): """ This is TargetNotFoundError BaseError When something is not found """ pass
[docs]class ScriptParamError(AirtestError): """ This is ScriptParamError BaseError When something goes wrong """ pass
[docs]class AdbError(Exception): """ This is AdbError BaseError When ADB have something wrong """ def __init__(self, stdout, stderr): self.stdout = stdout self.stderr = stderr def __str__(self): return "stdout[%s] stderr[%s]" % (self.stdout, self.stderr)
[docs]class AdbShellError(AdbError): """ adb shell error """ pass
[docs]class DeviceConnectionError(BaseError): """ device connection error """ DEVICE_CONNECTION_ERROR = r"error:\s*((device \'\S+\' not found)|(cannot connect to daemon at [\w\:\s\.]+ Connection timed out))" pass
[docs]class NoDeviceError(BaseError): """ When no device is connected """ pass
[docs]class ICmdError(Exception): """ This is ICmdError BaseError When ICmd have something wrong """ def __init__(self, stdout, stderr): self.stdout = stdout self.stderr = stderr def __str__(self): return "stdout[%s] stderr[%s]" %(self.stdout, self.stderr)
[docs]class ScreenError(BaseError): """ When the screen capture method(Minicap/Javacap/ScreenProxy) has something wrong """ pass
[docs]class MinicapError(ScreenError): """ This is MinicapError BaseError When Minicap have something wrong """ pass
[docs]class MinitouchError(BaseError): """ This is MinitouchError BaseError When Minicap have something wrong """ pass
[docs]class PerformanceError(BaseError): pass
[docs]class LocalDeviceError(BaseError): """ Custom exception for calling a method on a non-local iOS device. """ def __init__(self, value="Can only use this method on a local device."): super().__init__(value)