Skip to content

Commit b69b167

Browse files
authored
Merge pull request #204 from pmonks/issue-203
Addresses issue #203
2 parents ae14e24 + 3c53d40 commit b69b167

File tree

12 files changed

+38
-38
lines changed

12 files changed

+38
-38
lines changed

src/main/java/org/spdx/library/model/SpdxModelFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public static Optional<ModelObject> getModelObject(IModelStore modelStore, Strin
294294
try {
295295
return Optional.of(new ExternalSpdxElement(modelStore, documentUri, id, copyManager, true));
296296
} catch(InvalidSPDXAnalysisException ex) {
297-
logger.warn("Attempting to get a model object for an invalid SPDX ID. Returning empty");
297+
logger.warn("Attempting to get a model object for an invalid SPDX ID. Returning empty", ex);
298298
return Optional.empty();
299299
}
300300
}

src/main/java/org/spdx/library/model/license/LicenseExpressionParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static AnyLicenseInfo parseLicenseExpression(String expression, IModelStore stor
9393
// Add the expression to the error message to provide additional information to the user
9494
throw new LicenseParserException(ex.getMessage()+" License expression: '"+expression+"'", ex);
9595
} catch (EmptyStackException ex) {
96-
throw new LicenseParserException("Invalid license expression: '"+expression+"' - check that every operator (e.g. AND and OR) has operators and that parenthesis are matched");
96+
throw new LicenseParserException("Invalid license expression: '"+expression+"' - check that every operator (e.g. AND and OR) has operators and that parenthesis are matched", ex);
9797
}
9898
}
9999
}

src/main/java/org/spdx/library/model/license/LicenseInfoFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static AnyLicenseInfo parseSPDXLicenseString(String licenseString, @Nulla
8787
} catch (LicenseParserException e) {
8888
throw new InvalidLicenseStringException(e.getMessage(),e);
8989
} catch (InvalidSPDXAnalysisException e) {
90-
throw new InvalidLicenseStringException("Unexpected SPDX error parsing license string");
90+
throw new InvalidLicenseStringException("Unexpected SPDX error parsing license string", e);
9191
}
9292
}
9393

src/main/java/org/spdx/library/model/license/ListedLicenses.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ private static Properties loadLicenseProperties() {
8585
}
8686
} catch (IOException e) {
8787
// Ignore it and fall through
88-
logger.warn("IO Exception reading listed license properties file: " + e.getMessage());
88+
logger.warn("IO Exception reading listed license properties file: " + e.getMessage(), e);
8989
} finally {
9090
if (in != null) {
9191
try {
9292
in.close();
9393
} catch (IOException e) {
94-
logger.warn("Unable to close listed license properties file: " + e.getMessage());
94+
logger.warn("Unable to close listed license properties file: " + e.getMessage(), e);
9595
}
9696
}
9797
}
@@ -108,16 +108,16 @@ private void initializeLicenseModelStore() {
108108
try {
109109
licenseModelStore = new SpdxListedLicenseWebStore();
110110
} catch(InvalidSPDXAnalysisException ex) {
111-
logger.error("Unable to access the most current listed licenses from https://spdx.org/licenses - using locally cached licenses: "+ex.getMessage());
111+
logger.error("Unable to access the most current listed licenses from https://spdx.org/licenses - using locally cached licenses: "+ex.getMessage(), ex);
112112
licenseModelStore = null;
113113
}
114114
}
115115
if (licenseModelStore == null) {
116116
try {
117117
licenseModelStore = new SpdxListedLicenseLocalStore();
118118
} catch(InvalidSPDXAnalysisException ex) {
119-
logger.error("Error loading cached SPDX licenses");
120-
throw new RuntimeException("Unexpected error loading SPDX Listed Licenses");
119+
logger.error("Error loading cached SPDX licenses", ex);
120+
throw new RuntimeException("Unexpected error loading SPDX Listed Licenses", ex);
121121
}
122122
}
123123
} finally {

src/main/java/org/spdx/library/model/license/SpdxListedLicense.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public String getLicenseTextHtml() throws InvalidLicenseTemplateException, Inval
146146
try {
147147
return SpdxLicenseTemplateHelper.templateTextToHtml(templateText);
148148
} catch(LicenseTemplateRuleException ex) {
149-
throw new InvalidLicenseTemplateException("Invalid license expression found in license text for license "+getName()+":"+ex.getMessage());
149+
throw new InvalidLicenseTemplateException("Invalid license expression found in license text for license "+getName()+":"+ex.getMessage(), ex);
150150
}
151151
} else {
152152
return SpdxLicenseTemplateHelper.formatEscapeHTML(this.getLicenseText());
@@ -179,7 +179,7 @@ public String getLicenseHeaderHtml() throws InvalidLicenseTemplateException, Inv
179179
try {
180180
return SpdxLicenseTemplateHelper.templateTextToHtml(templateText);
181181
} catch(LicenseTemplateRuleException ex) {
182-
throw new InvalidLicenseTemplateException("Invalid license expression found in standard license header for license "+getName()+":"+ex.getMessage());
182+
throw new InvalidLicenseTemplateException("Invalid license expression found in standard license header for license "+getName()+":"+ex.getMessage(), ex);
183183
}
184184
} else {
185185
return SpdxLicenseTemplateHelper.formatEscapeHTML(this.getStandardLicenseHeader());

src/main/java/org/spdx/library/referencetype/ListedReferenceTypes.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private ListedReferenceTypes() {
6666
}
6767
} catch (IOException e) {
6868
logger.warn("IO Exception reading listed reference type properties file: "
69-
+ e.getMessage() + ", loading properties from class properties file.");
69+
+ e.getMessage() + ", loading properties from class properties file.", e);
7070
}
7171
if (Objects.isNull(in)) {
7272
try {
@@ -77,15 +77,15 @@ private ListedReferenceTypes() {
7777
logger.error("Unable to load listed reference type properties");
7878
}
7979
} catch (IOException ex2) {
80-
logger.error("IO exception reading listed reference type properties from class properties file: "+ex2.getMessage());
80+
logger.error("IO exception reading listed reference type properties from class properties file: "+ex2.getMessage(), ex2);
8181
}
8282
}
8383
} finally {
8484
if (in != null) {
8585
try {
8686
in.close();
8787
} catch (IOException e) {
88-
logger.warn("Unable to close listed license properties file: " + e.getMessage());
88+
logger.warn("Unable to close listed license properties file: " + e.getMessage(), e);
8989
}
9090
}
9191
}
@@ -165,7 +165,7 @@ public URI getListedReferenceUri(String listedReferenceName) throws InvalidSPDXA
165165
retval = new URI(SpdxConstants.SPDX_LISTED_REFERENCE_TYPES_PREFIX + listedReferenceName);
166166
} catch (URISyntaxException e) {
167167
logger.error("Error forming listed license URI",e);
168-
throw new InvalidSPDXAnalysisException(listedReferenceName + " is not a valid SPDX listed reference type syntax.");
168+
throw new InvalidSPDXAnalysisException(listedReferenceName + " is not a valid SPDX listed reference type syntax.",e);
169169
}
170170
if (!isListedReferenceType(retval)) {
171171
throw new InvalidSPDXAnalysisException(listedReferenceName + " is not a valid SPDX listed reference type.");

src/main/java/org/spdx/storage/listedlicense/SpdxListedLicenseModelStore.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,15 @@ private void loadIds() throws InvalidSPDXAnalysisException {
170170
ExceptionJsonTOC exceptionToc = gson.fromJson(tocJsonStr.toString(), ExceptionJsonTOC.class);
171171
exceptionIds = exceptionToc.getExceptionIds();
172172
} catch (MalformedURLException e) {
173-
throw new SpdxListedLicenseException("License TOC URL invalid") ;
173+
throw new SpdxListedLicenseException("License TOC URL invalid", e) ;
174174
} catch (IOException e) {
175-
throw new SpdxListedLicenseException("I/O error reading license TOC");
175+
throw new SpdxListedLicenseException("I/O error reading license TOC", e);
176176
} finally {
177177
if (reader != null) {
178178
try {
179179
reader.close();
180180
} catch (IOException e) {
181-
logger.warn("Unable to close JSON TOC reader");
181+
logger.warn("Unable to close JSON TOC reader", e);
182182
}
183183
}
184184
}
@@ -326,23 +326,23 @@ private LicenseJson fetchLicenseJson(String idCaseInsensitive) throws InvalidSPD
326326
LicenseJson license = gson.fromJson(licenseJsonStr.toString(), LicenseJson.class);
327327
this.listedLicenseCache.put(id, license);
328328
} catch (MalformedURLException e) {
329-
logger.error("Json license invalid for ID "+id);
330-
throw new SpdxListedLicenseException("JSON license URL invalid for ID "+id);
329+
logger.error("Json license invalid for ID "+id, e);
330+
throw new SpdxListedLicenseException("JSON license URL invalid for ID "+id, e);
331331
} catch (IOException e) {
332-
logger.error("I/O error opening Json license URL");
333-
throw new SpdxListedLicenseException("I/O Error reading license data for ID "+id);
332+
logger.error("I/O error opening Json license URL", e);
333+
throw new SpdxListedLicenseException("I/O Error reading license data for ID "+id, e);
334334
} finally {
335335
if (reader != null) {
336336
try {
337337
reader.close();
338338
} catch (IOException e) {
339-
logger.warn("Unable to close JSON TOC reader");
339+
logger.warn("Unable to close JSON TOC reader", e);
340340
}
341341
} else if (jsonStream != null) {
342342
try {
343343
jsonStream.close();
344344
} catch (IOException e) {
345-
logger.warn("Unable to close JSON TOC input stream");
345+
logger.warn("Unable to close JSON TOC input stream", e);
346346
}
347347
}
348348
}
@@ -398,22 +398,22 @@ private ExceptionJson fetchExceptionJson(String idCaseInsensitive) throws Invali
398398
this.listedExceptionCache.put(id, exc);
399399
} catch (MalformedURLException e) {
400400
logger.error("Json license invalid for ID "+id);
401-
throw new SpdxListedLicenseException("JSON license URL invalid for ID "+id);
401+
throw new SpdxListedLicenseException("JSON license URL invalid for ID "+id, e);
402402
} catch (IOException e) {
403403
logger.error("I/O error opening Json license URL");
404-
throw new SpdxListedLicenseException("I/O Error reading license data for ID "+id);
404+
throw new SpdxListedLicenseException("I/O Error reading license data for ID "+id, e);
405405
} finally {
406406
if (reader != null) {
407407
try {
408408
reader.close();
409409
} catch (IOException e) {
410-
logger.warn("Unable to close JSON TOC reader");
410+
logger.warn("Unable to close JSON TOC reader", e);
411411
}
412412
} else if (jsonStream != null) {
413413
try {
414414
jsonStream.close();
415415
} catch (IOException e) {
416-
logger.warn("Unable to close JSON TOC input stream");
416+
logger.warn("Unable to close JSON TOC input stream", e);
417417
}
418418
}
419419
}

src/main/java/org/spdx/storage/listedlicense/SpdxListedLicenseWebStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private InputStream getUrlInputStream(URL url) throws IOException {
6363
try {
6464
redirectUrl = new URL(redirectUrlStr);
6565
} catch(Exception ex) {
66-
throw new IOException("Invalid redirect URL");
66+
throw new IOException("Invalid redirect URL", ex);
6767
}
6868
if (!redirectUrl.getProtocol().toLowerCase().startsWith("http")) {
6969
throw new IOException("Invalid redirect protocol");

src/main/java/org/spdx/storage/simple/StoredTypedItem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public boolean addValueToList(String propertyName, Object value) throws SpdxInva
200200
}
201201
return list.add(value);
202202
} catch (Exception ex) {
203-
throw new SpdxInvalidTypeException("Invalid list type for "+propertyName);
203+
throw new SpdxInvalidTypeException("Invalid list type for "+propertyName, ex);
204204
}
205205
}
206206

@@ -222,7 +222,7 @@ public boolean removeTypedValueFromList(String propertyName, TypedValue value) t
222222
}
223223
return list.remove(value);
224224
} catch (Exception ex) {
225-
throw new SpdxInvalidTypeException("Invalid list type for "+propertyName);
225+
throw new SpdxInvalidTypeException("Invalid list type for "+propertyName, ex);
226226
}
227227
}
228228

@@ -257,7 +257,7 @@ public boolean removeValueFromList(String propertyName, Object value) throws Spd
257257
}
258258
return list.remove(value);
259259
} catch (Exception ex) {
260-
throw new SpdxInvalidTypeException("Invalid list type for "+propertyName);
260+
throw new SpdxInvalidTypeException("Invalid list type for "+propertyName, ex);
261261
}
262262
}
263263

src/main/java/org/spdx/utility/compare/LicenseCompareHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,14 @@ public static String removeCommentChars(String s) {
244244
}
245245
return sb.toString();
246246
} catch (IOException e) {
247-
logger.warn("IO error reading strings?!?");
247+
logger.warn("IO error reading strings?!?", e);
248248
return s;
249249
} finally {
250250
if (Objects.nonNull(reader)) {
251251
try {
252252
reader.close();
253253
} catch (IOException e) {
254-
logger.warn("IO error closing a string reader?!?");
254+
logger.warn("IO error closing a string reader?!?", e);
255255
}
256256
}
257257
}

0 commit comments

Comments
 (0)