Sergei Trofimov | 4e6afe9 | 2015-10-09 09:30:04 +0100 | [diff] [blame] | 1 | # 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 Trofimov | 4e6afe9 | 2015-10-09 09:30:04 +0100 | [diff] [blame] | 17 | class DevlibError(Exception): |
Brendan Jackman | 1fa6f92 | 2017-03-01 18:54:54 +0000 | [diff] [blame^] | 18 | """Base class for all Devlib exceptions.""" |
Sergei Trofimov | 4e6afe9 | 2015-10-09 09:30:04 +0100 | [diff] [blame] | 19 | pass |
| 20 | |
| 21 | |
| 22 | class TargetError(DevlibError): |
| 23 | """An error has occured on the target""" |
| 24 | pass |
| 25 | |
| 26 | |
| 27 | class 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 | |
| 34 | class HostError(DevlibError): |
| 35 | """An error has occured on the host""" |
| 36 | pass |
| 37 | |
Sergei Trofimov | a926503 | 2017-02-08 11:14:40 +0000 | [diff] [blame] | 38 | |
| 39 | class 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 '']) |