Fix Sonar error-handling issues 29/8329/1
authorMarek Gradzki <mgradzki@cisco.com>
Thu, 7 Sep 2017 10:22:28 +0000 (12:22 +0200)
committerMarek Gradzki <mgradzki@cisco.com>
Thu, 7 Sep 2017 10:22:28 +0000 (12:22 +0200)
Change-Id: Iae8a7d27ed4ba778abe5bdbb937f55fa4d7a6638
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
common/yang-whitelist/yang-whitelist-impl/src/main/java/io/fd/honeycomb/yang/YangModuleWhitelistWriter.java
infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/ResourceLoader.java
infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/YangDataProcessor.java
infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/annotations/InjectablesProcessor.java

index d14b242..02bdfe1 100644 (file)
@@ -66,7 +66,7 @@ public class YangModuleWhitelistWriter extends JAXBContextHolder {
         try {
             marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, value);
         } catch (PropertyException e) {
-            throw new IllegalStateException("Unable to setup pretty print");
+            throw new IllegalStateException("Unable to setup pretty print", e);
         }
     }
 
index 60aaaae..88428e8 100644 (file)
@@ -108,7 +108,7 @@ public interface ResourceLoader {
             try {
                 return jar.getInputStream(jarEntry);
             } catch (IOException e) {
-                throw new IllegalStateException(format("Unable to get stream for entry %s | jar %s", jar, jarEntry));
+                throw new IllegalStateException(format("Unable to get stream for entry %s | jar %s", jar, jarEntry), e);
             }
         }
 
@@ -116,7 +116,7 @@ public interface ResourceLoader {
             try {
                 return url.toURI();
             } catch (URISyntaxException e) {
-                throw new IllegalStateException(format("Unable to convert URL %s to URI", url));
+                throw new IllegalStateException(format("Unable to convert URL %s to URI", url), e);
             }
         }
 
index 7c04eac..6722d01 100644 (file)
@@ -78,7 +78,7 @@ interface YangDataProcessor {
         try {
             parentInstanceId = serializer.toBinding(parentYangId);
         } catch (DeserializationException e) {
-            throw new IllegalArgumentException(String.format("Unable to deserialize %s", parentYangId));
+            throw new IllegalArgumentException(String.format("Unable to deserialize %s", parentYangId), e);
         }
 
         if (!parentInstanceId.isPresent()) {
@@ -108,7 +108,7 @@ interface YangDataProcessor {
                         throw new IllegalArgumentException(String.format("Unable to create node binding  for %s|%s", identifier, data));
                     });
         } catch (DeserializationException e) {
-            throw new IllegalArgumentException(String.format("Unable to deserialize node %s|%s", identifier, data));
+            throw new IllegalArgumentException(String.format("Unable to deserialize node %s|%s", identifier, data), e);
         }
     }
 
@@ -121,7 +121,7 @@ interface YangDataProcessor {
                         throw new IllegalArgumentException(String.format("Unable convert %s to binding", identifier));
                     });
         } catch (DeserializationException e) {
-            throw new IllegalArgumentException(String.format("Unable to deserialize %s", identifier));
+            throw new IllegalArgumentException(String.format("Unable to deserialize %s", identifier), e);
         }
     }
 }
index c09f26e..0afb890 100644 (file)
@@ -77,7 +77,7 @@ public interface InjectablesProcessor {
         try {
             FieldUtils.writeField(field, testInstance, data);
         } catch (IllegalAccessException e) {
-            throw new IllegalStateException("Unable to access field " + field);
+            throw new IllegalStateException("Unable to access field " + field, e);
         }
     }
 
@@ -85,9 +85,9 @@ public interface InjectablesProcessor {
         try {
             return YangInstanceIdentifier.of(QName.class.cast(type.getField("QNAME").get(null)));
         } catch (IllegalAccessException e) {
-            throw new IllegalStateException("Constant QNAME not accessible for type" + type);
+            throw new IllegalStateException("Constant QNAME not accessible for type" + type, e);
         } catch (NoSuchFieldException e) {
-            throw new IllegalStateException("Class " + type + " does not have QName defined");
+            throw new IllegalStateException("Class " + type + " does not have QName defined", e);
         }
     }