Add YangError.getErrorTag() 94/96694/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 25 Jun 2021 16:00:14 +0000 (18:00 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 28 Jun 2021 12:25:39 +0000 (14:25 +0200)
Error tags are well-defined and mandatory-to-include in NETCONF/YANG
error handling model. Make sure we expose this information from
YangError (and by extension from YangInvalidValueException).

JIRA: YANGTOOLS-1301
Change-Id: Ie914fda40b04facf56c5d644c41b3c91a8948dcd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 54ada00ff849ed9c8391d6e3ca1764cb9c84e53f)

yang/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/YangError.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/codec/YangInvalidValueException.java

index 3c01af26b9c86bf7801c1da9cf715102c5be7aec..a925c5bf270108a2fee3cf36d5e0bdded26cf035 100644 (file)
@@ -36,14 +36,21 @@ public interface YangError {
     @NonNull ErrorSeverity getSeverity();
 
     /**
-     * Returns the value of the argument of YANG <code>error-app-tag</code> keyword.
+     * Returns the error tag, as determined by the application reporting the error.
      *
-     * @return string with the application tag, or empty if it was not provided.
+     * @return an error tag.
+     */
+    @NonNull String getErrorTag();
+
+    /**
+     * Returns the value of the argument of YANG {@code error-app-tag} statement.
+     *
+     * @return string with the application error tag, or empty if it was not provided.
      */
     Optional<String> getErrorAppTag();
 
     /**
-     * Returns the value of the argument of YANG <code>error-message</code> keyword.
+     * Returns the value of the argument of YANG {@code error-message} statement.
      *
      * @return string with the error message, or empty if it was not provided.
      */
index a666bbaf14fb083e1c82918ffa7a45aa0da6d1f8..5e845ed7963940006910484ca8c610c07487e0bf 100644 (file)
@@ -60,6 +60,11 @@ public class YangInvalidValueException extends IllegalArgumentException implemen
         return ErrorSeverity.ERROR;
     }
 
+    @Override
+    public final String getErrorTag() {
+        return "invalid-value";
+    }
+
     @Override
     public final Optional<String> getErrorAppTag() {
         return Optional.ofNullable(errorAppTag);