summaryrefslogtreecommitdiffstats
path: root/build/android/pylib/device/device_errors.py
blob: 7cfc87370536d5cd4d81feec3c6501cd845725cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""
Exception classes raised by AdbWrapper and DeviceUtils.
"""

class BaseError(Exception):
  """Base exception for all device and command errors."""
  pass


class CommandFailedError(BaseError):
  """Exception for command failures."""

  def __init__(self, msg, device=None):
    super(CommandFailedError, self).__init__(
        '%s%s' % ('(device: %s) ' % device if device else '', msg))


class AdbCommandFailedError(CommandFailedError):
  """Exception for adb command failures."""

  def __init__(self, cmd, msg, device=None):
    super(AdbCommandFailedError, self).__init__(
        'adb command \'%s\' failed with message: \'%s\'' % (' '.join(cmd), msg),
        device=device)


class CommandTimeoutError(BaseError):
  """Exception for command timeouts."""
  pass


class DeviceUnreachableError(BaseError):
  """Exception for device unreachable failures."""
  pass