2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.netconf.api;
11 import java.util.Collections;
14 import org.opendaylight.protocol.framework.DocumentedException;
17 * Checked exception to communicate an error that needs to be sent to the
20 public class NetconfDocumentedException extends DocumentedException {
22 private static final long serialVersionUID = 1L;
24 public enum ErrorType {
25 transport, rpc, protocol, application;
27 public String getTagValue() {
32 public enum ErrorTag {
33 missing_attribute("missing-attribute"), unknown_element("unknown-element"), operation_not_supported(
34 "operation-not-supported"), bad_attribute("bad-attribute"), data_missing("data-missing"), operation_failed(
35 "operation-failed"), invalid_value("invalid-value"), malformed_message("malformed-message");
37 private final String tagValue;
39 ErrorTag(final String tagValue) {
40 this.tagValue = tagValue;
43 public String getTagValue() {
48 public enum ErrorSeverity {
51 public String getTagValue() {
56 private final ErrorType errorType;
57 private final ErrorTag errorTag;
58 private final ErrorSeverity errorSeverity;
59 private final Map<String, String> errorInfo;
61 public NetconfDocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag,
62 final ErrorSeverity errorSeverity) {
63 this(message, errorType, errorTag, errorSeverity, Collections.<String, String> emptyMap());
66 public NetconfDocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag,
67 final ErrorSeverity errorSeverity, final Map<String, String> errorInfo) {
69 this.errorType = errorType;
70 this.errorTag = errorTag;
71 this.errorSeverity = errorSeverity;
72 this.errorInfo = errorInfo;
75 public NetconfDocumentedException(final String message, final Exception cause, final ErrorType errorType,
76 final ErrorTag errorTag, final ErrorSeverity errorSeverity) {
77 this(message, cause, errorType, errorTag, errorSeverity, Collections.<String, String> emptyMap());
80 public NetconfDocumentedException(final String message, final Exception cause, final ErrorType errorType,
81 final ErrorTag errorTag, final ErrorSeverity errorSeverity, final Map<String, String> errorInfo) {
82 super(message, cause);
83 this.errorType = errorType;
84 this.errorTag = errorTag;
85 this.errorSeverity = errorSeverity;
86 this.errorInfo = errorInfo;
89 public ErrorType getErrorType() {
90 return this.errorType;
93 public ErrorTag getErrorTag() {
97 public ErrorSeverity getErrorSeverity() {
98 return this.errorSeverity;
101 public Map<String, String> getErrorInfo() {
102 return this.errorInfo;
106 public String toString() {
107 return "NetconfDocumentedException{" + "message=" + getMessage() + ", errorType=" + this.errorType
108 + ", errorTag=" + this.errorTag + ", errorSeverity=" + this.errorSeverity + ", errorInfo="
109 + this.errorInfo + '}';