Bug 451 - Fix netconf exception handling
[controller.git] / opendaylight / netconf / netconf-api / src / main / java / org / opendaylight / controller / netconf / api / NetconfDocumentedException.java
index ceeca51defdff65016a842faaa97bfcdc165d6ae..57bd3dd6209d3248dc7c7b969ccaf6f5a33fbbf7 100644 (file)
@@ -90,6 +90,12 @@ public class NetconfDocumentedException extends Exception {
         this.errorInfo = errorInfo;
     }
 
+    public static <E extends Exception> NetconfDocumentedException wrap(E exception) throws NetconfDocumentedException {
+        final Map<String, String> errorInfo = new HashMap<>();
+        errorInfo.put(ErrorTag.operation_failed.name(), "Exception thrown");
+        throw new NetconfDocumentedException(exception.getMessage(), exception, ErrorType.application, ErrorTag.operation_failed,
+                ErrorSeverity.error, errorInfo);
+    }
     public static NetconfDocumentedException wrap(ValidationException e) throws NetconfDocumentedException {
         final Map<String, String> errorInfo = new HashMap<>();
         errorInfo.put(ErrorTag.operation_failed.name(), "Validation failed");