From a08f4c288f0d737bfb9fc6799b78c56416054582 Mon Sep 17 00:00:00 2001 From: Michael Franklin Date: Wed, 1 Sep 2021 22:54:31 +1000 Subject: [PATCH] Add exception handling to fromwdl Suggested: https://github.com/PMCC-BioinformaticsCore/janis/pull/58#pullrequestreview-743869634 Co-authored-by: Michael R. Crusoe --- janis_core/ingestion/fromwdl.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/janis_core/ingestion/fromwdl.py b/janis_core/ingestion/fromwdl.py index 80c466497..db4d736a5 100755 --- a/janis_core/ingestion/fromwdl.py +++ b/janis_core/ingestion/fromwdl.py @@ -3,6 +3,7 @@ import os import re from types import LambdaType + from typing import List, Union, Optional, Callable import WDL @@ -447,6 +448,16 @@ def parse_command_tool_output(self, outp: WDL.Decl): toolname = sys.argv[1] - tool = WdlParser.from_doc(toolname) - - tool.translate("janis") + try: + tool = WdlParser.from_doc(toolname) + tool.translate("janis") + + except WDL.Error.MultipleValidationErrors as err: + for exc in err.exceptions: + print(exc, file=sys.stderr) + print(exc.pos, file=sys.stderr) + print(exc.node, file=sys.stderr) + except WDL.Error.ValidationError as exc: + print(exc, file=sys.stderr) + print(exc.pos, file=sys.stderr) + print(exc.node, file=sys.stderr)