1#!/usr/bin/env python3 2# coding=utf-8 3 4# 5# Copyright (c) 2020-2022 Huawei Device Co., Ltd. 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17# 18from xdevice import DeviceError 19 20__all__ = ["LiteDeviceConnectError", "LiteDeviceTimeout", "LiteParamError", 21 "LiteDeviceError", "LiteDeviceExecuteCommandError", 22 "LiteDeviceMountError", "LiteDeviceReadOutputError"] 23 24 25class LiteDeviceError(Exception): 26 def __init__(self, error_msg, error_no=""): 27 super(LiteDeviceError, self).__init__(error_msg, error_no) 28 self.error_msg = error_msg 29 self.error_no = error_no 30 31 def __str__(self): 32 return str(self.error_msg) 33 34 35class LiteDeviceConnectError(LiteDeviceError): 36 def __init__(self, error_msg, error_no=""): 37 super(LiteDeviceConnectError, self).__init__(error_msg, error_no) 38 self.error_msg = error_msg 39 self.error_no = error_no 40 41 def __str__(self): 42 return str(self.error_msg) 43 44 45class LiteDeviceTimeout(LiteDeviceError): 46 def __init__(self, error_msg, error_no=""): 47 super(LiteDeviceTimeout, self).__init__( 48 error_msg, error_no) 49 self.error_msg = error_msg 50 self.error_no = error_no 51 52 def __str__(self): 53 return str(self.error_msg) 54 55 56class LiteParamError(LiteDeviceError): 57 def __init__(self, error_msg, error_no=""): 58 super(LiteParamError, self).__init__(error_msg, error_no) 59 self.error_msg = error_msg 60 self.error_no = error_no 61 62 def __str__(self): 63 return str(self.error_msg) 64 65 66class LiteDeviceExecuteCommandError(LiteDeviceError): 67 def __init__(self, error_msg, error_no=""): 68 super(LiteDeviceExecuteCommandError, self).__init__( 69 error_msg, error_no) 70 self.error_msg = error_msg 71 self.error_no = error_no 72 73 def __str__(self): 74 return str(self.error_msg) 75 76 77class LiteDeviceMountError(LiteDeviceError): 78 def __init__(self, error_msg, error_no=""): 79 super(LiteDeviceMountError, self).__init__(error_msg, error_no) 80 self.error_msg = error_msg 81 self.error_no = error_no 82 83 def __str__(self): 84 return str(self.error_msg) 85 86 87class LiteDeviceReadOutputError(LiteDeviceError): 88 def __init__(self, error_msg, error_no=""): 89 super(LiteDeviceReadOutputError, self).__init__(error_msg, error_no) 90 self.error_msg = error_msg 91 self.error_no = error_no 92 93 def __str__(self): 94 return str(self.error_msg) 95 96