X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fapi%2FNetconfDocumentedException.java;h=ceeca51defdff65016a842faaa97bfcdc165d6ae;hp=5a85e9425783c4171ce41d52b01dd71b9a3c9079;hb=7d9b07a6cf8171e97eb5ce6ed4ccdcfadff8e741;hpb=2e92a15f60261432cde594d86f033802f7410e17 diff --git a/opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfDocumentedException.java b/opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfDocumentedException.java index 5a85e94257..ceeca51def 100644 --- a/opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfDocumentedException.java +++ b/opendaylight/netconf/netconf-api/src/main/java/org/opendaylight/controller/netconf/api/NetconfDocumentedException.java @@ -8,7 +8,11 @@ package org.opendaylight.controller.netconf.api; +import org.opendaylight.controller.config.api.ConflictingVersionException; +import org.opendaylight.controller.config.api.ValidationException; + import java.util.Collections; +import java.util.HashMap; import java.util.Map; /** @@ -19,6 +23,8 @@ public class NetconfDocumentedException extends Exception { private static final long serialVersionUID = 1L; + + public enum ErrorType { transport, rpc, protocol, application; @@ -84,6 +90,20 @@ public class NetconfDocumentedException extends Exception { this.errorInfo = errorInfo; } + public static NetconfDocumentedException wrap(ValidationException e) throws NetconfDocumentedException { + final Map errorInfo = new HashMap<>(); + errorInfo.put(ErrorTag.operation_failed.name(), "Validation failed"); + throw new NetconfDocumentedException(e.getMessage(), e, ErrorType.application, ErrorTag.operation_failed, + ErrorSeverity.error, errorInfo); + } + + public static NetconfDocumentedException wrap(ConflictingVersionException e) throws NetconfDocumentedException { + final Map errorInfo = new HashMap<>(); + errorInfo.put(ErrorTag.operation_failed.name(), "Optimistic lock failed"); + throw new NetconfDocumentedException(e.getMessage(), e, ErrorType.application, ErrorTag.operation_failed, + ErrorSeverity.error, errorInfo); + } + public ErrorType getErrorType() { return this.errorType; }