Fix checkstyle error for java 8 build success
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / RpcUtil.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.openflowplugin.openflow.md.core;
9
10 import org.opendaylight.yangtools.yang.common.RpcError;
11 import org.opendaylight.yangtools.yang.common.RpcResult;
12
13 /**
14  * @author mirehak
15  *
16  */
17 public abstract class RpcUtil {
18
19     /**
20      * @param result rpc result
21      * @throws Exception exception thrown by method if rpc fails
22      */
23     public static void smokeRpc(RpcResult<?> result) throws Exception {
24         if (!result.isSuccessful()) {
25             Throwable firstCause = null;
26             StringBuilder sb = new StringBuilder();
27             for (RpcError error : result.getErrors()) {
28                 if (firstCause != null) {
29                     firstCause = error.getCause();
30                 }
31                 
32                 sb.append("rpcError:").append(error.getCause().getMessage()).append(';');
33             }
34             throw new Exception(sb.toString(), firstCause);
35         }
36     }
37
38 }