blob: 16dd04fa4acd7ff35bc830538fb4bc751ccf2f7a [file] [log] [blame]
Sergei Trofimov4e6afe92015-10-09 09:30:04 +01001# Copyright 2013-2015 ARM Limited
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16
Sergei Trofimov4e6afe92015-10-09 09:30:04 +010017class DevlibError(Exception):
Brendan Jackman1fa6f922017-03-01 18:54:54 +000018 """Base class for all Devlib exceptions."""
Sergei Trofimov4e6afe92015-10-09 09:30:04 +010019 pass
20
21
22class TargetError(DevlibError):
23 """An error has occured on the target"""
24 pass
25
26
27class TargetNotRespondingError(DevlibError):
28 """The target is unresponsive."""
29
30 def __init__(self, target):
31 super(TargetNotRespondingError, self).__init__('Target {} is not responding.'.format(target))
32
33
34class HostError(DevlibError):
35 """An error has occured on the host"""
36 pass
37
Sergei Trofimova9265032017-02-08 11:14:40 +000038
39class TimeoutError(DevlibError):
40 """Raised when a subprocess command times out. This is basically a ``DevlibError``-derived version
41 of ``subprocess.CalledProcessError``, the thinking being that while a timeout could be due to
42 programming error (e.g. not setting long enough timers), it is often due to some failure in the
43 environment, and there fore should be classed as a "user error"."""
44
45 def __init__(self, command, output):
46 super(TimeoutError, self).__init__('Timed out: {}'.format(command))
47 self.command = command
48 self.output = output
49
50 def __str__(self):
51 return '\n'.join([self.message, 'OUTPUT:', self.output or ''])