From 038ae3c95e060ab3c698e1a2c178762c429eb21d Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Tue, 6 Sep 2022 13:58:25 -0500 Subject: graphql: T4674: print included op-mode error message, if it exists --- src/services/api/graphql/graphql/mutations.py | 3 ++- src/services/api/graphql/graphql/queries.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/services/api') diff --git a/src/services/api/graphql/graphql/mutations.py b/src/services/api/graphql/graphql/mutations.py index 1b77cff87..5ccc9b0b6 100644 --- a/src/services/api/graphql/graphql/mutations.py +++ b/src/services/api/graphql/graphql/mutations.py @@ -90,11 +90,12 @@ def make_mutation_resolver(mutation_name, class_name, session_func): } except OpModeError as e: typename = type(e).__name__ + msg = str(e) return { "success": False, "errore": ['op_mode_error'], "op_mode_error": {"name": f"{typename}", - "message": op_mode_err_msg.get(typename, "Unknown"), + "message": msg if msg else op_mode_err_msg.get(typename, "Unknown"), "vyos_code": op_mode_err_code.get(typename, 9999)} } except Exception as error: diff --git a/src/services/api/graphql/graphql/queries.py b/src/services/api/graphql/graphql/queries.py index 8ae61b704..b46914dcc 100644 --- a/src/services/api/graphql/graphql/queries.py +++ b/src/services/api/graphql/graphql/queries.py @@ -90,11 +90,12 @@ def make_query_resolver(query_name, class_name, session_func): } except OpModeError as e: typename = type(e).__name__ + msg = str(e) return { "success": False, "errors": ['op_mode_error'], "op_mode_error": {"name": f"{typename}", - "message": op_mode_err_msg.get(typename, "Unknown"), + "message": msg if msg else op_mode_err_msg.get(typename, "Unknown"), "vyos_code": op_mode_err_code.get(typename, 9999)} } except Exception as error: -- cgit v1.2.3