Bug 2366 - new parser API - implementation of declared statements
[yangtools.git] / yang / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / RpcError.java
index 8b6ef47beb037f9862457423e882a31ffd9c697b..3645637b893af4ba9998922ff86e2f59186d5b4a 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.yang.common;\r
-\r
-//import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;\r
-\r
-public interface RpcError {\r
-    ErrorSeverity getSeverity();\r
-\r
-    String getTag();\r
-\r
-    String getApplicationTag();\r
-\r
-    String getMessage();\r
-\r
-    String getInfo();\r
-\r
-    // RevisionAwareXPath getPath();\r
-\r
-    public enum ErrorSeverity {\r
-        ERROR, WARNING,\r
-    }\r
-\r
-    public enum ErrorType {\r
-        TRANSPORT, RPC, PROTOCOL, APPLICATION\r
-    }\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.common;
+
+/**
+ * Representation of an error.
+ *
+ */
+public interface RpcError {
+
+    public enum ErrorSeverity {
+        ERROR,
+        WARNING
+    }
+
+    public enum ErrorType {
+        /**
+         * Indicates an error occurred during transport of data, eg over the network.
+         */
+        TRANSPORT,
+
+        /**
+         * Indicates an error occurred during a remote procedure call.
+         */
+        RPC,
+
+        /**
+         * Indicates an error at a protocol layer, eg if invalid data was passed by the caller.
+         */
+        PROTOCOL,
+
+        /**
+         * Indicates an error occurred during internal processing.
+         */
+        APPLICATION
+    }
+
+    /**
+     * Returns the error severity, as determined by the application reporting the error.
+     *
+     * @return an {@link ErrorSeverity} enum.
+     */
+    ErrorSeverity getSeverity();
+
+    /**
+     * Returns a short string that identifies the general type of error condition.
+     * <p>
+     * The following outlines suggested values as defined by netconf (<a href="https://tools.ietf.org/html/rfc6241#page-89">RFC 6241</a>):
+     * <pre>
+     *    access-denied
+     *    bad-attribute
+     *    bad-element
+     *    data-exists
+     *    data-missing
+     *    in-use
+     *    invalid-value
+     *    lock-denied
+     *    malformed-message
+     *    missing-attribute
+     *    missing-element
+     *    operation-failed
+     *    operation-not-supported
+     *    resource-denied
+     *    rollback-failed
+     *    too-big
+     *    unknown-attribute
+     *    unknown-element
+     *    unknown-namespace
+     * </pre>
+     * @return a string if available or null otherwise.
+     */
+    String getTag();
+
+    /**
+     * Returns a short string that identifies the specific type of error condition as
+     * determined by the application reporting the error.
+     *
+     * @return a string if available or null otherwise.
+     */
+    String getApplicationTag();
+
+    /**
+     * Returns a string suitable for human display that describes the error
+     * condition.
+     *
+     * @return a message string.
+     */
+    String getMessage();
+
+    /**
+     *
+     * Returns a string containing additional information to provide extended
+     * and/or implementation-specific debugging information.
+     *
+     * @return a string if available or null otherwise.
+     */
+    String getInfo();
+
+    /**
+     *
+     * Returns an exception cause.
+     *
+     * @return a Throwable if the error was triggered by exception, null otherwise.
+     */
+    Throwable getCause();
+
+    /**
+     * Returns the conceptual layer at which the error occurred.
+     *
+     * @return an {@link ErrorType} enum.
+     */
+    ErrorType getErrorType();
+}