Skip to content

Commit a1de5fa

Browse files
committed
more exception tracebacks, when in debug mode
1 parent dc7fd2e commit a1de5fa

File tree

8 files changed

+35
-17
lines changed

8 files changed

+35
-17
lines changed

cwltool/command_line_tool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ def collect_output(
13421342
]
13431343
)
13441344
except OSError as e:
1345-
_logger.warning(str(e))
1345+
_logger.warning(str(e), exc_info=builder.debug)
13461346
except Exception:
13471347
_logger.error("Unexpected error from fs_access", exc_info=True)
13481348
raise

cwltool/cwlprov/provenance_profile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def declare_artefact(self, value: Any) -> ProvEntity:
546546
# FIXME: list value does not support adding "@id"
547547
return coll
548548
except TypeError:
549-
_logger.warning("Unrecognized type %s of %r", type(value), value)
549+
_logger.warning("Unrecognized type %s of %r", type(value), value, exc_info=True)
550550
# Let's just fall back to Python repr()
551551
entity = self.document.entity(uuid.uuid4().urn, {PROV_LABEL: repr(value)})
552552
self.research_object.add_uri(entity.identifier.uri)

cwltool/executors.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,10 @@ def _runner(
326326
self.exceptions.append(err)
327327
except Exception as err: # pylint: disable=broad-except
328328
_logger.exception(f"Got workflow error: {err}")
329-
self.exceptions.append(WorkflowException(str(err)))
329+
wf_exc = WorkflowException(str(err))
330+
wf_exc.__cause__ = err
331+
wf_exc.__suppress_context__ = True
332+
self.exceptions.append(wf_exc)
330333
finally:
331334
if runtime_context.workflow_eval_lock:
332335
with runtime_context.workflow_eval_lock:

cwltool/job.py

+20-7
Original file line numberDiff line numberDiff line change
@@ -376,17 +376,30 @@ def stderr_stdout_log_path(
376376
except OSError as e:
377377
if e.errno == 2:
378378
if runtime:
379-
_logger.error("'%s' not found: %s", runtime[0], str(e))
379+
_logger.error(
380+
"'%s' not found: %s", runtime[0], str(e), exc_info=runtimeContext.debug
381+
)
380382
else:
381-
_logger.error("'%s' not found: %s", self.command_line[0], str(e))
383+
_logger.error(
384+
"'%s' not found: %s",
385+
self.command_line[0],
386+
str(e),
387+
exc_info=runtimeContext.debug,
388+
)
382389
else:
383-
_logger.exception("Exception while running job")
390+
_logger.exception(
391+
"Exception while running job: %s", str(e), exc_info=runtimeContext.debug
392+
)
384393
processStatus = "permanentFail"
385394
except WorkflowException as err:
386-
_logger.error("[job %s] Job error:\n%s", self.name, str(err))
395+
_logger.error(
396+
"[job %s] Job error:\n%s", self.name, str(err), exc_info=runtimeContext.debug
397+
)
387398
processStatus = "permanentFail"
388-
except Exception:
389-
_logger.exception("Exception while running job")
399+
except Exception as err:
400+
_logger.exception(
401+
"Exception while running job: %s.", str(err), exc_info=runtimeContext.debug
402+
)
390403
processStatus = "permanentFail"
391404
if (
392405
runtimeContext.research_obj is not None
@@ -795,7 +808,7 @@ def run(
795808
)
796809
except Exception as err:
797810
container = "Singularity" if runtimeContext.singularity else "Docker"
798-
_logger.debug("%s error", container, exc_info=True)
811+
_logger.debug("%s error", container, exc_info=runtimeContext.debug)
799812
if docker_is_req:
800813
raise UnsupportedRequirement(
801814
f"{container} is required to run this tool: {str(err)}"

cwltool/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ def main(
12891289
if isinstance(err.code, int):
12901290
return err.code
12911291
else:
1292-
_logger.debug("Non-integer SystemExit: %s", err.code)
1292+
_logger.debug("Non-integer SystemExit: %s", err.code, exc_info=args.debug)
12931293
return 1
12941294

12951295
del args.workflow

cwltool/procgenerator.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def job(
5757
except WorkflowException:
5858
raise
5959
except Exception as exc:
60-
_logger.exception("Unexpected exception")
60+
_logger.exception("Unexpected exception", exc_info=runtimeContext.debug)
6161
raise WorkflowException(str(exc)) from exc
6262

6363

@@ -80,7 +80,7 @@ def __init__(
8080
self.embedded_tool = load_tool(toolpath_object["run"], loadingContext)
8181
except ValidationException as vexc:
8282
if loadingContext.debug:
83-
_logger.exception("Validation exception")
83+
_logger.exception("Validation exception", exc_info=loadingContext.debug)
8484
raise WorkflowException(
8585
"Tool definition %s failed validation:\n%s"
8686
% (toolpath_object["run"], indent(str(vexc)))
@@ -108,7 +108,7 @@ def result(
108108
)
109109
except ValidationException as vexc:
110110
if runtimeContext.debug:
111-
_logger.exception("Validation exception")
111+
_logger.exception("Validation exception", exc_info=runtimeContext.debug)
112112
raise WorkflowException(
113113
"Tool definition %s failed validation:\n%s"
114114
% (jobout["runProcess"], indent(str(vexc)))

cwltool/resolver.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def resolve_local(document_loader: Optional[Loader], uri: str) -> Optional[str]:
1515

1616
try:
1717
pathobj = Path(pathpart).resolve()
18-
except OSError:
19-
_logger.debug("local resolver could not resolve %s", uri)
18+
except OSError as exc:
19+
_logger.debug("local resolver could not resolve %s due to %s", uri, str(exc))
2020
return None
2121

2222
if pathobj.is_file():

cwltool/workflow.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,9 @@ def job(
442442
runtimeContext,
443443
)
444444
except WorkflowException:
445-
_logger.error("Exception on step '%s'", runtimeContext.name)
445+
_logger.error(
446+
"Exception on step '%s'", runtimeContext.name, exc_info=runtimeContext.debug
447+
)
446448
raise
447449
except Exception as exc:
448450
_logger.exception("Unexpected exception")

0 commit comments

Comments
 (0)