Skip to content

Commit

Permalink
[#302] some refactoring + improved error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernd Weigel committed Dec 3, 2024
1 parent fe414b8 commit 5f5228e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/java/com/xceptance/neodymium/util/LighthouseUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class LighthouseUtils
public static void createLightHouseReport(String reportName) throws Exception
{
// validate that lighthouse is installed
String readerOutput = "";
try
{
if (System.getProperty("os.name").toLowerCase().contains("win"))
Expand All @@ -53,6 +54,14 @@ else if (System.getProperty("os.name").toLowerCase().contains("linux") || System
try
{
Process p = runProcess("sh", "-c", Neodymium.configuration().lighthouseBinaryPath(), "--version");
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String readerLine;
while ((readerLine = r.readLine()) != null)
{
readerOutput = readerOutput + readerLine;
continue;
}

checkErrorCodeProcess(p);
}
catch (Exception e)
Expand All @@ -68,7 +77,9 @@ else if (System.getProperty("os.name").toLowerCase().contains("linux") || System
}
catch (Exception e)
{
throw new Exception("lighthouse binary not found at " + Neodymium.configuration().lighthouseBinaryPath() + ", please install lighthouse and add it to the PATH or enter the correct lighthouse binary location.", e);
throw new Exception("lighthouse binary can't be run (" + Neodymium.configuration().lighthouseBinaryPath()
+ "), please install lighthouse and add it to the PATH or enter the correct lighthouse binary location.\n\nProcess Log: "
+ readerOutput, e);
}

// validate chrome browser (lighthouse only works for chrome)
Expand Down Expand Up @@ -210,7 +221,7 @@ else if (System.getProperty("os.name").toLowerCase().contains("linux") || System
}
catch (IOException e)
{
throw new Exception("failed to run the process\n\nProcess Log: " + readerOutput, e);
throw new Exception("failed to run the lighthouse process. \n\nProcess Log: " + readerOutput, e);
}

}
Expand Down

0 comments on commit 5f5228e

Please sign in to comment.