Skip to content

Commit

Permalink
fixed error message creation code
Browse files Browse the repository at this point in the history
  • Loading branch information
stesee committed Apr 11, 2020
1 parent 59dafd3 commit 87b12e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions PdfAValidator/PdfAValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ public Report ValidateWithDetailedReport(string pathToPdfFile)
{
process.StartInfo.EnvironmentVariables["JAVACMD"] = PathJava;
}
var currentJavaCmd = process.StartInfo.EnvironmentVariables["JAVACMD"];
var startInfo = process.StartInfo;
// http://docs.verapdf.org/cli/terminal/
var arguments = new[] { maskedQuote, absolutePathToPdfFile, maskedQuote };
Expand All @@ -136,14 +135,14 @@ public Report ValidateWithDetailedReport(string pathToPdfFile)

if (process.ExitCode == 0)
{
validateVeraPdfOutputToBeXml(outputResult, currentJavaCmd, VeraPdfStartScript);
validateVeraPdfOutputToBeXml(outputResult, PathJava, VeraPdfStartScript);
var veraPdfReport = DeserializeXml<Report>(outputResult);
return veraPdfReport;
}
throw new VeraPdfException($"Calling VeraPdf exited with {process.ExitCode} caused an error: {errorResult}\nJAVACMD: {currentJavaCmd}\nVeraPdfStartScript: {VeraPdfStartScript}");
throw new VeraPdfException($"Calling VeraPdf exited with {process.ExitCode} caused an error: {errorResult}\nCustom JAVACMD: {PathJava}\nVeraPdfStartScript: {VeraPdfStartScript}");
}

private void validateVeraPdfOutputToBeXml(string outputResult, string currentJavaCmd, string veraPdfStartScript)
private void validateVeraPdfOutputToBeXml(string outputResult, string? customJavaCmd, string? veraPdfStartScript)
{
try
{
Expand All @@ -152,7 +151,7 @@ private void validateVeraPdfOutputToBeXml(string outputResult, string currentJav
}
catch (XmlException xmlException)
{
throw new VeraPdfException($"Failed to parse VeraPdf Ouput: {outputResult}\n currentJavaCmd: {currentJavaCmd}\n veraPdfStartScriptPath: {veraPdfStartScript}", xmlException);
throw new VeraPdfException($"Failed to parse VeraPdf Ouput: {outputResult}\nCustom JAVACMD: {customJavaCmd}\nveraPdfStartScriptPath: {veraPdfStartScript}", xmlException);
}
}

Expand Down
4 changes: 2 additions & 2 deletions PdfAValidatorTest/PdfAValidatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static void ShouldFailGracefullWithUnrecognicedVeraPdfOutput()
}
Assert.False(File.Exists(veraPdfStartScript));
});
Assert.Equal($"Failed to parse VeraPdf Ouput: \n currentJavaCmd: SomeValue\n veraPdfStartScriptPath: {somethingThatReturnsExitcode0}", veraPdfException.Message);
Assert.Equal($"Failed to parse VeraPdf Ouput: \nCustom JAVACMD: SomeValue\nveraPdfStartScriptPath: {somethingThatReturnsExitcode0}", veraPdfException.Message);
}

[Fact]
Expand Down Expand Up @@ -156,7 +156,7 @@ public static void ShouldFailGracefullWithExitcode1()
}
Assert.False(File.Exists(veraPdfStartScript));
});
Assert.Equal($"Calling VeraPdf exited with 1 caused an error: \nJAVACMD: SomeValue\nVeraPdfStartScript: {somethingThatReturnsExitcode1}", veraPdfException.Message);
Assert.Equal($"Calling VeraPdf exited with 1 caused an error: \nCustom JAVACMD: SomeValue\nVeraPdfStartScript: {somethingThatReturnsExitcode1}", veraPdfException.Message);
}

private static void AssertVeraPdfBinCreation(string? scriptPath)
Expand Down

0 comments on commit 87b12e1

Please sign in to comment.