# -*- coding: utf-8 -*-
"""
error classes
"""
[文档]class BaseError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
[文档]class AirtestError(BaseError):
"""
This is Airtest BaseError
"""
pass
[文档]class InvalidMatchingMethodError(BaseError):
"""
This is InvalidMatchingMethodError BaseError
When an invalid matching method is used in settings.
"""
pass
[文档]class TargetNotFoundError(AirtestError):
"""
This is TargetNotFoundError BaseError
When something is not found
"""
pass
[文档]class ScriptParamError(AirtestError):
"""
This is ScriptParamError BaseError
When something goes wrong
"""
pass
[文档]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)
[文档]class AdbShellError(AdbError):
"""
adb shell error
"""
pass
[文档]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
[文档]class NoDeviceError(BaseError):
"""
When no device is connected
"""
pass
[文档]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)
[文档]class ScreenError(BaseError):
"""
When the screen capture method(Minicap/Javacap/ScreenProxy) has something wrong
"""
pass
[文档]class MinicapError(ScreenError):
"""
This is MinicapError BaseError
When Minicap have something wrong
"""
pass
[文档]class MinitouchError(BaseError):
"""
This is MinitouchError BaseError
When Minicap have something wrong
"""
pass
[文档]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)