Skip to content

Commit e8757c2

Browse files
authoredJan 31, 2017
Merge pull request spdx#87 from timurphy/master
Add parse error details to exception message
2 parents 7c46518 + cc3a63e commit e8757c2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎src/org/spdx/rdfparser/SpdxDocumentContainer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ public void getExtractedLicenseInfosFromModel() throws InvalidSPDXAnalysisExcept
561561

562562
for (int i = 0; i < extractedAnyLicenseInfo.length; i++) {
563563
if (!(extractedAnyLicenseInfo[i] instanceof ExtractedLicenseInfo)) {
564-
throw new InvalidSPDXAnalysisException("Invalid type for extracted license infos");
564+
throw new InvalidSPDXAnalysisException("Invalid type for extracted license infos: " + extractedAnyLicenseInfo[i]);
565565
}
566566
ExtractedLicenseInfo lic = (ExtractedLicenseInfo)extractedAnyLicenseInfo[i];
567567
this.licenseIdToExtractedLicense.put(lic.getLicenseId(), lic);

‎src/org/spdx/tools/CompareSpdxDocs.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,7 @@ protected static SpdxDocument openRdfOrTagDoc(String spdxDocFileName, List<Strin
11381138
}
11391139

11401140
SpdxDocument retval = null;
1141+
String errorDetails = "(no error details available)";
11411142
try {
11421143
// Try to open the file as a tag/value file first.
11431144
retval = convertTagValueToRdf(spdxDocFile, warnings);
@@ -1151,15 +1152,18 @@ protected static SpdxDocument openRdfOrTagDoc(String spdxDocFileName, List<Strin
11511152
retval = SPDXDocumentFactory.createSpdxDocument(spdxDocFileName);
11521153
logger.info("Document identified as SPDX RDF/XML.");
11531154
} catch (IOException e) {
1155+
errorDetails = e.getMessage();
11541156
// Ignore - unrecognized files are handled below.
11551157
} catch (InvalidSPDXAnalysisException e) {
1158+
errorDetails = e.getMessage();
11561159
// Ignore - unrecognized files are handled below.
11571160
} catch (Exception e) {
1161+
errorDetails = e.getMessage();
11581162
// Ignore - unrecognized files are handled below.
11591163
}
11601164
}
11611165
if (retval == null) {
1162-
throw(new SpdxCompareException("File "+spdxDocFileName+" is not a recognized RDF/XML or tag/value format"));
1166+
throw(new SpdxCompareException("File "+spdxDocFileName+" is not a recognized RDF/XML or tag/value format: " + errorDetails));
11631167
}
11641168
return retval;
11651169
}

0 commit comments

Comments
 (0)