10497: Add source line reporting to errors and fix tests to work with CommentedMap...
[arvados.git] / sdk / cwl / arvados_cwl / pathmapper.py
index 74d9481ff53003a458fa38e237b84342ad6fd427..e63161dbb1f9ef3d685ec82e7f9d3fc5b1e3e482 100644 (file)
@@ -6,6 +6,8 @@ import os
 import arvados.commands.run
 import arvados.collection
 
+from schema_salad.sourceline import SourceLine
+
 from cwltool.pathmapper import PathMapper, MapperEnt, abspath, adjustFileObjs, adjustDirObjs
 from cwltool.workflow import WorkflowException
 
@@ -46,11 +48,11 @@ class ArvPathMapper(PathMapper):
                     if "contents" in srcobj:
                         pass
                     else:
-                        raise WorkflowException("File literal '%s' is missing contents" % src)
+                        raise SourceLine(srcobj, "location", WorkflowException).makeError("File literal '%s' is missing contents" % src)
                 elif src.startswith("arvwf:"):
                     self._pathmap[src] = MapperEnt(src, src, "File")
                 else:
-                    raise WorkflowException("Input file path '%s' is invalid" % st)
+                    raise SourceLine(srcobj, "location", WorkflowException).makeError("Input file path '%s' is invalid" % st)
             if "secondaryFiles" in srcobj:
                 for l in srcobj["secondaryFiles"]:
                     self.visit(l, uploadfiles)
@@ -76,7 +78,7 @@ class ArvPathMapper(PathMapper):
             with c.open(path + "/" + obj["basename"], "w") as f:
                 f.write(obj["contents"].encode("utf-8"))
         else:
-            raise WorkflowException("Don't know what to do with '%s'" % obj["location"])
+            raise SourceLine(obj, "location", WorkflowException).makeError("Don't know what to do with '%s'" % obj["location"])
 
     def setup(self, referenced_files, basedir):
         # type: (List[Any], unicode) -> None