From 743964feee6f1c59989e48da59261342f9bd9e09 Mon Sep 17 00:00:00 2001 From: Michael Pollmeier Date: Mon, 29 Jan 2024 20:57:05 +0100 Subject: [PATCH] more details on test error (#4097) * more details on test error (this would have saved me some time debugging a downstream issue) * fmt --- .../scala/io/shiftleft/semanticcpg/testing/package.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/semanticcpg/src/main/scala/io/shiftleft/semanticcpg/testing/package.scala b/semanticcpg/src/main/scala/io/shiftleft/semanticcpg/testing/package.scala index 8c19cad49d69..bc1fd33422a1 100644 --- a/semanticcpg/src/main/scala/io/shiftleft/semanticcpg/testing/package.scala +++ b/semanticcpg/src/main/scala/io/shiftleft/semanticcpg/testing/package.scala @@ -131,7 +131,10 @@ package object testing { } if (fileName != "") { - val file = cpg.file.nameExact(fileName).head + val file = cpg.file + .nameExact(fileName) + .headOption + .getOrElse(throw new RuntimeException(s"file with name='$fileName' not found")) graph.addEdge(method, file, EdgeTypes.SOURCE_FILE) } }