mirror of
https://github.com/ARM-software/devlib.git
synced 2025-02-25 05:57:51 +00:00
target: Introduce KernelConfigKeyError
Make a new exception type raised by KernelConfig that inherits from both KeyError (exception raised by mappings) and IndexError (exception raised by sequences, but also raised here for backward compatibility).
This commit is contained in:
parent
a752f55956
commit
5b51c2644e
@ -105,6 +105,16 @@ class WorkerThreadError(DevlibError):
|
||||
super(WorkerThreadError, self).__init__(message)
|
||||
|
||||
|
||||
class KernelConfigKeyError(KeyError, IndexError, DevlibError):
|
||||
"""
|
||||
Exception raised when a kernel config option cannot be found.
|
||||
|
||||
It inherits from :exc:`IndexError` for backward compatibility, and
|
||||
:exc:`KeyError` to behave like a regular mapping.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def get_traceback(exc=None):
|
||||
"""
|
||||
Returns the string with the traceback for the specifiec exc
|
||||
|
@ -36,7 +36,7 @@ from devlib.module import get_module
|
||||
from devlib.platform import Platform
|
||||
from devlib.exception import (DevlibTransientError, TargetStableError,
|
||||
TargetNotRespondingError, TimeoutError,
|
||||
TargetTransientError) # pylint: disable=redefined-builtin
|
||||
TargetTransientError, KernelConfigKeyError) # pylint: disable=redefined-builtin
|
||||
from devlib.utils.ssh import SshConnection
|
||||
from devlib.utils.android import AdbConnection, AndroidProperties, LogcatMonitor, adb_command, adb_disconnect, INTENT_FLAGS
|
||||
from devlib.utils.misc import memoized, isiterable, convert_new_lines
|
||||
@ -1810,7 +1810,10 @@ class KernelConfig(object):
|
||||
res = self._config.get(name)
|
||||
|
||||
if not res and strict:
|
||||
raise IndexError("{} is not exposed in target's config")
|
||||
raise KernelConfigKeyError(
|
||||
"{} is not exposed in kernel config".format(name),
|
||||
name
|
||||
)
|
||||
|
||||
return self._config.get(name)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user