3645637b893af4ba9998922ff86e2f59186d5b4a
[yangtools.git] / yang / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / RpcError.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.common;
9
10 /**
11  * Representation of an error.
12  *
13  */
14 public interface RpcError {
15
16     public enum ErrorSeverity {
17         ERROR,
18         WARNING
19     }
20
21     public enum ErrorType {
22         /**
23          * Indicates an error occurred during transport of data, eg over the network.
24          */
25         TRANSPORT,
26
27         /**
28          * Indicates an error occurred during a remote procedure call.
29          */
30         RPC,
31
32         /**
33          * Indicates an error at a protocol layer, eg if invalid data was passed by the caller.
34          */
35         PROTOCOL,
36
37         /**
38          * Indicates an error occurred during internal processing.
39          */
40         APPLICATION
41     }
42
43     /**
44      * Returns the error severity, as determined by the application reporting the error.
45      *
46      * @return an {@link ErrorSeverity} enum.
47      */
48     ErrorSeverity getSeverity();
49
50     /**
51      * Returns a short string that identifies the general type of error condition.
52      * <p>
53      * The following outlines suggested values as defined by netconf (<a href="https://tools.ietf.org/html/rfc6241#page-89">RFC 6241</a>):
54      * <pre>
55      *    access-denied
56      *    bad-attribute
57      *    bad-element
58      *    data-exists
59      *    data-missing
60      *    in-use
61      *    invalid-value
62      *    lock-denied
63      *    malformed-message
64      *    missing-attribute
65      *    missing-element
66      *    operation-failed
67      *    operation-not-supported
68      *    resource-denied
69      *    rollback-failed
70      *    too-big
71      *    unknown-attribute
72      *    unknown-element
73      *    unknown-namespace
74      * </pre>
75      * @return a string if available or null otherwise.
76      */
77     String getTag();
78
79     /**
80      * Returns a short string that identifies the specific type of error condition as
81      * determined by the application reporting the error.
82      *
83      * @return a string if available or null otherwise.
84      */
85     String getApplicationTag();
86
87     /**
88      * Returns a string suitable for human display that describes the error
89      * condition.
90      *
91      * @return a message string.
92      */
93     String getMessage();
94
95     /**
96      *
97      * Returns a string containing additional information to provide extended
98      * and/or implementation-specific debugging information.
99      *
100      * @return a string if available or null otherwise.
101      */
102     String getInfo();
103
104     /**
105      *
106      * Returns an exception cause.
107      *
108      * @return a Throwable if the error was triggered by exception, null otherwise.
109      */
110     Throwable getCause();
111
112     /**
113      * Returns the conceptual layer at which the error occurred.
114      *
115      * @return an {@link ErrorType} enum.
116      */
117     ErrorType getErrorType();
118 }