refine more exception classes in port management
[racktables] / wwwroot / inc / functions.php
index 0886f14e6a1fda1f028aab46155181af7d0ecaed..2fc9720fe4378d1f0552f09184e7276302df7682 100644 (file)
@@ -6629,13 +6629,13 @@ function syncObjectPorts ($object_id, $desiredPorts)
                $real_ports[$key] = 1;
        }
        $to_add = array_diff_key ($desiredPorts, $real_ports);
-       foreach (array_merge ($to_update, $to_add) as $port)
-               if ($port['l2address'] != '' && alreadyUsedL2Address ($port['l2address'], $object_id))
-                       throw new InvalidRequestArgException ('l2address', $port['l2address'], 'address belongs to another object');
 
-       // Make the actual changes.
        try
        {
+               foreach (array_merge ($to_update, $to_add) as $port)
+                       if ($port['l2address'] != '' && alreadyUsedL2Address ($port['l2address'], $object_id))
+                               throw new InvalidRequestArgException ('l2address', $port['l2address'], 'address belongs to another object');
+               // Make the actual changes.
                foreach ($to_delete as $port)
                        if ($port['link_count'] != 0)
                                showWarning (sprintf ("Port %s should be deleted, but it's used", formatPort ($port)));