ed623cd7f10693c408bc524482e198300da26486
[netconf.git] / protocol / netconf-api / src / main / java / org / opendaylight / netconf / api / NetconfDocumentedException.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.netconf.api;
9
10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
11 import java.util.Map;
12 import org.opendaylight.yangtools.yang.common.ErrorSeverity;
13 import org.opendaylight.yangtools.yang.common.ErrorTag;
14 import org.opendaylight.yangtools.yang.common.ErrorType;
15 import org.w3c.dom.Document;
16
17 /**
18  * Checked exception to communicate an error that needs to be sent to the netconf client.
19  */
20 public class NetconfDocumentedException extends DocumentedException {
21     private static final long serialVersionUID = 1L;
22
23     public NetconfDocumentedException(final String message) {
24         super(message);
25     }
26
27     public NetconfDocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag,
28                                       final ErrorSeverity errorSeverity) {
29         super(message, errorType, errorTag, errorSeverity);
30     }
31
32     public NetconfDocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag,
33                                       final ErrorSeverity errorSeverity, final Map<String, String> errorInfo) {
34         super(message, errorType, errorTag, errorSeverity, errorInfo);
35     }
36
37     public NetconfDocumentedException(final String message, final Exception cause, final ErrorType errorType,
38                                       final ErrorTag errorTag, final ErrorSeverity errorSeverity) {
39         super(message, cause, errorType, errorTag, errorSeverity);
40     }
41
42     public NetconfDocumentedException(final String message, final Exception cause, final ErrorType errorType,
43                                       final ErrorTag errorTag, final ErrorSeverity errorSeverity,
44                                       final Map<String, String> errorInfo) {
45         super(message, cause, errorType, errorTag, errorSeverity, errorInfo);
46     }
47
48     @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
49     public NetconfDocumentedException(final DocumentedException exception) {
50         super(exception.getMessage(), (Exception) exception.getCause(), exception.getErrorType(),
51                 exception.getErrorTag(), exception.getErrorSeverity(), exception.getErrorInfo());
52     }
53
54     public static NetconfDocumentedException fromXMLDocument(final Document fromDoc) {
55         return new NetconfDocumentedException(DocumentedException.fromXMLDocument(fromDoc));
56     }
57 }