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;
15 * Checked exception to communicate an error that needs to be sent to the
18 public class NetconfDocumentedException extends Exception {
20 private static final long serialVersionUID = 1L;
22 public enum ErrorType {
23 transport, rpc, protocol, application;
25 public String getTagValue() {
30 public enum ErrorTag {
31 missing_attribute("missing-attribute"), unknown_element("unknown-element"), operation_not_supported(
32 "operation-not-supported"), bad_attribute("bad-attribute"), data_missing("data-missing"), operation_failed(
33 "operation-failed"), invalid_value("invalid-value"), malformed_message("malformed-message");
35 private final String tagValue;
37 ErrorTag(final String tagValue) {
38 this.tagValue = tagValue;
41 public String getTagValue() {
46 public enum ErrorSeverity {
49 public String getTagValue() {
54 private final ErrorType errorType;
55 private final ErrorTag errorTag;
56 private final ErrorSeverity errorSeverity;
57 private final Map<String, String> errorInfo;
59 public NetconfDocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag,
60 final ErrorSeverity errorSeverity) {
61 this(message, errorType, errorTag, errorSeverity, Collections.<String, String> emptyMap());
64 public NetconfDocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag,
65 final ErrorSeverity errorSeverity, final Map<String, String> errorInfo) {
67 this.errorType = errorType;
68 this.errorTag = errorTag;
69 this.errorSeverity = errorSeverity;
70 this.errorInfo = errorInfo;
73 public NetconfDocumentedException(final String message, final Exception cause, final ErrorType errorType,
74 final ErrorTag errorTag, final ErrorSeverity errorSeverity) {
75 this(message, cause, errorType, errorTag, errorSeverity, Collections.<String, String> emptyMap());
78 public NetconfDocumentedException(final String message, final Exception cause, final ErrorType errorType,
79 final ErrorTag errorTag, final ErrorSeverity errorSeverity, final Map<String, String> errorInfo) {
80 super(message, cause);
81 this.errorType = errorType;
82 this.errorTag = errorTag;
83 this.errorSeverity = errorSeverity;
84 this.errorInfo = errorInfo;
87 public ErrorType getErrorType() {
88 return this.errorType;
91 public ErrorTag getErrorTag() {
95 public ErrorSeverity getErrorSeverity() {
96 return this.errorSeverity;
99 public Map<String, String> getErrorInfo() {
100 return this.errorInfo;
104 public String toString() {
105 return "NetconfDocumentedException{" + "message=" + getMessage() + ", errorType=" + this.errorType
106 + ", errorTag=" + this.errorTag + ", errorSeverity=" + this.errorSeverity + ", errorInfo="
107 + this.errorInfo + '}';