Add YangError.getErrorTag()
[yangtools.git] / common / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / YangError.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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 import com.google.common.annotations.Beta;
11 import java.util.Optional;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
14 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
15
16 /**
17  * An error condition raised as a consequence of a YANG-defined contract. This interface should not be directly
18  * implemented, but rather should be attached to a well-defined Exception class.
19  *
20  * @author Robert Varga
21  */
22 @Beta
23 public interface YangError {
24     /**
25      * Returns the conceptual layer at which the error occurred.
26      *
27      * @return an {@link ErrorType} enum.
28      */
29     @NonNull ErrorType getErrorType();
30
31     /**
32      * Returns the error severity, as determined by the application reporting the error.
33      *
34      * @return an {@link ErrorSeverity} enum.
35      */
36     @NonNull ErrorSeverity getSeverity();
37
38     /**
39      * Returns the error tag, as determined by the application reporting the error.
40      *
41      * @return an error tag.
42      */
43     @NonNull String getErrorTag();
44
45     /**
46      * Returns the value of the argument of YANG {@code error-app-tag} statement.
47      *
48      * @return string with the application error tag, or empty if it was not provided.
49      */
50     Optional<String> getErrorAppTag();
51
52     /**
53      * Returns the value of the argument of YANG {@code error-message} statement.
54      *
55      * @return string with the error message, or empty if it was not provided.
56      */
57     Optional<String> getErrorMessage();
58 }