Update RESTCONF error mapping
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / jersey / providers / JsonNormalizedNodeBodyReader.java
index 0cd836d55b8b1ec6e036fa1094e7ced45206258a..63093012522b37ff59fa6d8cb4a10710b467a36b 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.jersey.providers;
 
+import com.google.common.base.Throwables;
 import com.google.common.collect.Iterables;
 import com.google.gson.stream.JsonReader;
 import java.io.InputStream;
@@ -134,19 +135,15 @@ public class JsonNormalizedNodeBodyReader extends AbstractNormalizedNodeBodyRead
     }
 
     private static void propagateExceptionAs(final Exception exception) throws RestconfDocumentedException {
-        if (exception instanceof RestconfDocumentedException) {
-            throw (RestconfDocumentedException)exception;
-        }
+        Throwables.throwIfInstanceOf(exception, RestconfDocumentedException.class);
+        LOG.debug("Error parsing json input", exception);
 
         if (exception instanceof ResultAlreadySetException) {
-            LOG.debug("Error parsing json input:", exception);
-
             throw new RestconfDocumentedException("Error parsing json input: Failed to create new parse result data. "
                     + "Are you creating multiple resources/subresources in POST request?", exception);
         }
 
-        LOG.debug("Error parsing json input", exception);
-
+        RestconfDocumentedException.throwIfYangError(exception);
         throw new RestconfDocumentedException("Error parsing input: " + exception.getMessage(), ErrorType.PROTOCOL,
                 ErrorTag.MALFORMED_MESSAGE, exception);
     }