• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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#
18
19
20class ParamError(Exception):
21    def __init__(self, error_msg, error_no=""):
22        super(ParamError, self).__init__(error_msg, error_no)
23        self.error_msg = error_msg
24        self.error_no = error_no
25
26    def __str__(self):
27        return str(self.error_msg)
28
29
30class DeviceError(Exception):
31    def __init__(self, error_msg, error_no=""):
32        super(DeviceError, self).__init__(error_msg, error_no)
33        self.error_msg = error_msg
34        self.error_no = error_no
35
36    def __str__(self):
37        return str(self.error_msg)
38
39
40class ExecuteTerminate(Exception):
41    def __init__(self, error_msg="ExecuteTerminate", error_no=""):
42        super(ExecuteTerminate, self).__init__(error_msg, error_no)
43        self.error_msg = error_msg
44        self.error_no = error_no
45
46    def __str__(self):
47        return str(self.error_msg)
48
49
50class ReportException(Exception):
51    """
52    Exception thrown when a shell command executed on a device takes too long
53    to send its output.
54    """
55    def __init__(self, error_msg="ReportException", error_no=""):
56        super(ReportException, self).__init__(error_msg, error_no)
57        self.error_msg = error_msg
58        self.error_no = error_no
59
60    def __str__(self):
61        return str(self.error_msg)
62
63
64class LiteDeviceError(Exception):
65    def __init__(self, error_msg, error_no=""):
66        super(LiteDeviceError, self).__init__(error_msg, error_no)
67        self.error_msg = error_msg
68        self.error_no = error_no
69
70    def __str__(self):
71        return str(self.error_msg)
72
73
74class HdcError(DeviceError):
75    """
76    Raised when there is an error in hdc operations.
77    """
78
79    def __init__(self, error_msg, error_no=""):
80        super(HdcError, self).__init__(error_msg, error_no)
81        self.error_msg = error_msg
82        self.error_no = error_no
83
84    def __str__(self):
85        return str(self.error_msg)
86
87
88class HdcCommandRejectedException(HdcError):
89    """
90    Exception thrown when hdc refuses a command.
91    """
92
93    def __init__(self, error_msg, error_no=""):
94        super(HdcCommandRejectedException, self).__init__(error_msg, error_no)
95        self.error_msg = error_msg
96        self.error_no = error_no
97
98    def __str__(self):
99        return str(self.error_msg)
100
101
102class ShellCommandUnresponsiveException(HdcError):
103    """
104    Exception thrown when a shell command executed on a device takes too long
105    to send its output.
106    """
107    def __init__(self, error_msg="ShellCommandUnresponsiveException",
108                 error_no=""):
109        super(ShellCommandUnresponsiveException, self).\
110            __init__(error_msg, error_no)
111        self.error_msg = error_msg
112        self.error_no = error_no
113
114    def __str__(self):
115        return str(self.error_msg)
116
117
118class DeviceUnresponsiveException(HdcError):
119    """
120    Exception thrown when a shell command executed on a device takes too long
121    to send its output.
122    """
123    def __init__(self, error_msg="DeviceUnresponsiveException", error_no=""):
124        super(DeviceUnresponsiveException, self).__init__(error_msg, error_no)
125        self.error_msg = error_msg
126        self.error_no = error_no
127
128    def __str__(self):
129        return str(self.error_msg)
130
131
132class AppInstallError(DeviceError):
133    def __init__(self, error_msg, error_no=""):
134        super(AppInstallError, self).__init__(error_msg, error_no)
135        self.error_msg = error_msg
136        self.error_no = error_no
137
138    def __str__(self):
139        return str(self.error_msg)
140
141
142class HapNotSupportTest(DeviceError):
143    def __init__(self, error_msg, error_no=""):
144        super(HapNotSupportTest, self).__init__(error_msg, error_no)
145        self.error_msg = error_msg
146        self.error_no = error_no
147
148    def __str__(self):
149        return str(self.error_msg)
150
151
152class RpcNotRunningError(DeviceError):
153    def __init__(self, error_msg, error_no=""):
154        super(RpcNotRunningError, self).__init__(error_msg, error_no)
155        self.error_msg = error_msg
156        self.error_no = error_no
157
158    def __str__(self):
159        return str(self.error_msg)
160