From 613bc589926329dbdc48759514fb212025c3dd8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20S=C3=A9chet?= Date: Fri, 25 Feb 2022 16:52:39 +0100 Subject: [PATCH] wcs: Improved error reporting when importing a file of the wrong type (#62109) --- wcs/blocks.py | 2 +- wcs/formdef.py | 2 +- wcs/workflows.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wcs/blocks.py b/wcs/blocks.py index 99c10930..62f24bb8 100644 --- a/wcs/blocks.py +++ b/wcs/blocks.py @@ -176,7 +176,7 @@ class BlockDef(StorableObject): tree = tree.getroot() if tree.tag != cls.xml_root_node: - raise BlockdefImportError(_('Unexpected root node')) + raise BlockdefImportError(_('The provided file isn\'t a block, but a %s)' % tree.tag)) if include_id and tree.attrib.get('id'): blockdef.id = tree.attrib.get('id') diff --git a/wcs/formdef.py b/wcs/formdef.py index a8eb2893..13cdab6f 100644 --- a/wcs/formdef.py +++ b/wcs/formdef.py @@ -1351,7 +1351,7 @@ class FormDef(StorableObject): tree = tree.getroot() if tree.tag != cls.xml_root_node: - raise FormdefImportError(_('Unexpected root node')) + raise FormdefImportError(_('The provided file isn\'t a form, but a %s)' % tree.tag)) if include_id and tree.attrib.get('id'): formdef.id = tree.attrib.get('id') diff --git a/wcs/workflows.py b/wcs/workflows.py index 91aeacb9..f7ca9db0 100644 --- a/wcs/workflows.py +++ b/wcs/workflows.py @@ -851,8 +851,8 @@ class Workflow(StorableObject): if not ET.iselement(tree): tree = tree.getroot() - if tree.tag != 'workflow': - raise WorkflowImportError(_('Not a workflow')) + if tree.tag != cls.xml_root_node: + raise WorkflowImportError(_('The provided file isn\'t a workflow, but a %s)' % tree.tag)) if include_id and tree.attrib.get('id'): workflow.id = tree.attrib.get('id') -- 2.34.1