IllegalArgument Exception changed to Preconditions checks
[bgpcep.git] / bgp / parser-api / src / main / java / org / opendaylight / protocol / bgp / parser / BGPError.java
index f3e98dd80a7febe8613cea688a321cf221683db2..4bed06f59b6cc7a6e887242e26dae5a7c939a900 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.protocol.bgp.parser;
 
+import com.google.common.base.Preconditions;
 import com.google.common.collect.Maps;
 import java.util.Map;
 
@@ -172,9 +173,7 @@ public enum BGPError {
 
     public static BGPError forValue(final int code, final int subcode) {
         final BGPError e = VALUE_MAP.get(new BGPErrorIdentifier((short) code, (short) subcode));
-        if (e != null) {
-            return e;
-        }
-        throw new IllegalArgumentException("BGP Error code " + code + " and subcode " + subcode + " not recognized.");
+        Preconditions.checkArgument(e != null, "BGP Error code %s and subcode %s not recognized.", code, subcode);
+        return e;
     }
 }