diff options
author | Daniil Baturin <daniil@vyos.io> | 2022-08-04 12:51:27 -0400 |
---|---|---|
committer | Daniil Baturin <daniil@vyos.io> | 2022-08-04 12:51:27 -0400 |
commit | 46173f284cd971c4201969fa9fd35121c7cf7a3a (patch) | |
tree | c51c7945432c27bf1186c757a2112a99a30aab27 /python/vyos | |
parent | e199ae2dd5636f9177234bb05b77f4a0c9543428 (diff) | |
download | vyos-1x-46173f284cd971c4201969fa9fd35121c7cf7a3a.tar.gz vyos-1x-46173f284cd971c4201969fa9fd35121c7cf7a3a.zip |
T2719: add an exception hierarchy for op mode errors
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/opmode.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/python/vyos/opmode.py b/python/vyos/opmode.py index 0af4359c6..628f7b3a2 100644 --- a/python/vyos/opmode.py +++ b/python/vyos/opmode.py @@ -18,6 +18,33 @@ import sys import typing +class Error(Exception): + """ Any error that makes requested operation impossible to complete + for reasons unrelated to the user input or script logic. + """ + pass + +class UnconfiguredSubsystem(Error): + """ Requested operation is valid, but cannot be completed + because corresponding subsystem is not configured and running. + """ + pass + +class DataUnavailable(Error): + """ Requested operation is valid, but cannot be completed + because data for it is not available. + This error MAY be treated as temporary because such issues + are often caused by transient events such as service restarts. + """ + pass + +class PermissionDenied(Error): + """ Requested operation is valid, but the caller has no permission + to perform it. + """ + pass + + def _is_op_mode_function_name(name): if re.match(r"^(show|clear|reset|restart)", name): return True |