mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
xml module: Improve error message for missing namespaces
This commit is contained in:
committed by
Dag Wieers
parent
785e604c57
commit
16ca412bd7
@@ -545,8 +545,11 @@ def set_target_inner(module, tree, xpath, namespaces, attribute, value):
|
|||||||
if not is_node(tree, xpath, namespaces):
|
if not is_node(tree, xpath, namespaces):
|
||||||
changed = check_or_make_target(module, tree, xpath, namespaces)
|
changed = check_or_make_target(module, tree, xpath, namespaces)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
module.fail_json(msg="Xpath %s causes a failure: %s\n -- tree is %s" %
|
missing_namespace = ""
|
||||||
(xpath, e, etree.tostring(tree, pretty_print=True)), exception=traceback.format_exc(e))
|
if len(tree.getroot().nsmap) > 0 and ":" not in xpath:
|
||||||
|
missing_namespace = "XML document has namespace(s) defined, but no namespace prefix(es) used in xpath!\n"
|
||||||
|
module.fail_json(msg="%sXpath %s causes a failure: %s\n -- tree is %s" %
|
||||||
|
(missing_namespace, xpath, e, etree.tostring(tree, pretty_print=True)), exception=traceback.format_exc())
|
||||||
|
|
||||||
if not is_node(tree, xpath, namespaces):
|
if not is_node(tree, xpath, namespaces):
|
||||||
module.fail_json(msg="Xpath %s does not reference a node! tree is %s" %
|
module.fail_json(msg="Xpath %s does not reference a node! tree is %s" %
|
||||||
|
|||||||
Reference in New Issue
Block a user