xml module: Improve error message for missing namespaces
This commit is contained in:
parent
785e604c57
commit
16ca412bd7
1 changed files with 5 additions and 2 deletions
|
@ -545,8 +545,11 @@ def set_target_inner(module, tree, xpath, namespaces, attribute, value):
|
|||
if not is_node(tree, xpath, namespaces):
|
||||
changed = check_or_make_target(module, tree, xpath, namespaces)
|
||||
except Exception as e:
|
||||
module.fail_json(msg="Xpath %s causes a failure: %s\n -- tree is %s" %
|
||||
(xpath, e, etree.tostring(tree, pretty_print=True)), exception=traceback.format_exc(e))
|
||||
missing_namespace = ""
|
||||
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):
|
||||
module.fail_json(msg="Xpath %s does not reference a node! tree is %s" %
|
||||
|
|
Loading…
Reference in a new issue