Eliminate ErrorTag special case 46/97446/2
authorRobert Varga <[email protected]>
Sat, 11 Sep 2021 11:04:21 +0000 (13:04 +0200)
committerRobert Varga <[email protected]>
Sat, 11 Sep 2021 11:41:39 +0000 (13:41 +0200)
We now have YangError.getErrorTag(), hence we can eliminate this ugly
special case.

Change-Id: I2d2f51a05c8e8e68e5ad97f57cf923d16384c30d
Signed-off-by: Robert Varga <[email protected]>
restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/errors/RestconfDocumentedException.java

index d09003857abc34c00fa33a4d7a70050d886046ac..ac010cd659f60cd671e01e4a60eb6503bcf58895 100644 (file)
@@ -24,9 +24,6 @@ import org.opendaylight.yangtools.yang.common.OperationFailedException;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.YangError;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.codec.YangInvalidValueException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Unchecked exception to communicate error information, as defined in the ietf restcong draft, to be sent to the
@@ -39,7 +36,6 @@ import org.slf4j.LoggerFactory;
  * @author Thomas Pantelis
  */
 public class RestconfDocumentedException extends WebApplicationException {
-    private static final Logger LOG = LoggerFactory.getLogger(RestconfDocumentedException.class);
     private static final long serialVersionUID = 1L;
 
     private final ImmutableList<RestconfError> errors;
@@ -242,9 +238,8 @@ public class RestconfDocumentedException extends WebApplicationException {
         if (cause instanceof YangError) {
             final YangError error = (YangError) cause;
             throw new RestconfDocumentedException(cause, new RestconfError(error.getErrorType().toNetconf(),
-                // FIXME: this is a special-case until we have YangError.getTag()
-                cause instanceof YangInvalidValueException ? ErrorTag.INVALID_VALUE : ErrorTag.MALFORMED_MESSAGE,
-                    error.getErrorMessage().orElse(null), error.getErrorAppTag().orElse(null)));
+                new ErrorTag(error.getErrorTag()), error.getErrorMessage().orElse(null),
+                error.getErrorAppTag().orElse(null)));
         }
     }