Bug 1392: Change ReadTransaction#read to return CheckedFuture
[controller.git] / opendaylight / md-sal / sal-common-api / src / main / java / org / opendaylight / controller / md / sal / common / api / data / TransactionCommitFailedException.java
index 18a857e1d5c4bd0816674a6af99070c2a9dc1e76..7ac76e47b15048bbabfe70f49ed1c19fa48deb12 100644 (file)
@@ -7,14 +7,8 @@
  */
 package org.opendaylight.controller.md.sal.common.api.data;
 
-import java.util.Arrays;
-import java.util.List;
-
+import org.opendaylight.yangtools.yang.common.OperationFailedException;
 import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
-
-import com.google.common.collect.ImmutableList;
 
 /**
  *
@@ -24,41 +18,16 @@ import com.google.common.collect.ImmutableList;
  * failed.
  *
  */
-public class TransactionCommitFailedException extends Exception {
+public class TransactionCommitFailedException extends OperationFailedException {
 
     private static final long serialVersionUID = 1L;
 
-    private final List<RpcError> errorList;
-
     public TransactionCommitFailedException(final String message, final RpcError... errors) {
         this(message, null, errors);
     }
 
     public TransactionCommitFailedException(final String message, final Throwable cause,
                                             final RpcError... errors) {
-        super(message, cause);
-
-        if( errors != null && errors.length > 0 ) {
-            errorList = ImmutableList.<RpcError>builder().addAll( Arrays.asList( errors ) ).build();
-        }
-        else {
-            // Add a default RpcError.
-            errorList = ImmutableList.of(RpcResultBuilder.newError(ErrorType.APPLICATION, null,
-                    getMessage(), null, null, getCause()));
-        }
-    }
-
-    /**
-     * Returns additional error information about this exception.
-     *
-     * @return a List of RpcErrors. There is always at least one RpcError.
-     */
-    public List<RpcError> getErrorList() {
-        return errorList;
-    }
-
-    @Override
-    public String getMessage() {
-        return new StringBuilder( super.getMessage() ).append(", errors: ").append( errorList ).toString();
+        super(message, cause, errors);
     }
 }