diff options
author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2022-08-05 10:31:20 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-05 10:31:20 +0300 |
commit | 2a10ffa4b5074be27458159fa94d6227d0e5c7f7 (patch) | |
tree | fca060b0b0e5b05eb10b53c4a5a4fddd9ed7bc48 /python | |
parent | dfb4ce2a5aa4b2d8726ed08cd3ef301e611f57de (diff) | |
parent | 46173f284cd971c4201969fa9fd35121c7cf7a3a (diff) | |
download | vyos-1x-2a10ffa4b5074be27458159fa94d6227d0e5c7f7.tar.gz vyos-1x-2a10ffa4b5074be27458159fa94d6227d0e5c7f7.zip |
Merge pull request #1459 from dmbaturin/genop-exn
T2719: add an exception hierarchy for op mode errors
Diffstat (limited to 'python')
-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 |