diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-08-27 14:36:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-27 14:36:10 +0200 |
commit | 8dcb865d5d7b98cc76cd134125b76ffc04adef52 (patch) | |
tree | 3a61359a182d38c8ebc6c5b6676194f2df6f833d /src/services/api/graphql/session/session.py | |
parent | 557b9b8dd234fefcfa8e95c06d4dd30cfb3f7fd5 (diff) | |
parent | b4646149b4993578707833df96e972f76a298ef7 (diff) | |
download | vyos-1x-8dcb865d5d7b98cc76cd134125b76ffc04adef52.tar.gz vyos-1x-8dcb865d5d7b98cc76cd134125b76ffc04adef52.zip |
Merge pull request #1493 from jestabro/gql-op-mode-error
graphql: T4640: add schema defs and resolver support for op-mode errors
Diffstat (limited to 'src/services/api/graphql/session/session.py')
-rw-r--r-- | src/services/api/graphql/session/session.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/services/api/graphql/session/session.py b/src/services/api/graphql/session/session.py index 23bc7154c..93e1c328e 100644 --- a/src/services/api/graphql/session/session.py +++ b/src/services/api/graphql/session/session.py @@ -22,6 +22,7 @@ from vyos.config import Config from vyos.configtree import ConfigTree from vyos.defaults import directories from vyos.template import render +from vyos.opmode import Error as OpModeError from api.graphql.utils.util import load_op_mode_as_module, split_compound_op_mode_name @@ -177,10 +178,10 @@ class Session: mod = load_op_mode_as_module(f'{scriptname}') func = getattr(mod, func_name) - if len(list(data)) > 0: + try: res = func(True, **data) - else: - res = func(True) + except OpModeError as e: + raise e return res @@ -199,9 +200,9 @@ class Session: mod = load_op_mode_as_module(f'{scriptname}') func = getattr(mod, func_name) - if len(list(data)) > 0: + try: res = func(**data) - else: - res = func() + except OpModeError as e: + raise e return res |