Browse Source

catch keyerror when trying to remove a non-existent zone

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/f2f200910@294 e5f2f494-b856-4b98-b285-d166d9295462
Jelte Jansen 15 years ago
parent
commit
488453a9a3
1 changed files with 7 additions and 2 deletions
  1. 7 2
      src/lib/bind-cfgd/python/bind-cfgd.py

+ 7 - 2
src/lib/bind-cfgd/python/bind-cfgd.py

@@ -65,8 +65,13 @@ class ConfigManager:
                     self.add_zone(cmd[2])
                     answer["result"] = [ 0 ]
                 elif cmd[0] == "zone" and cmd[1] == "remove":
-                    self.remove_zone(cmd[2])
-                    answer["result"] = [ 0 ]
+                    try:
+                        self.remove_zone(cmd[2])
+                        answer["result"] = [ 0 ]
+                    except KeyError:
+                        # zone wasn't there, should we make
+                        # a separate exception for that?
+                        answer["result"] = [ 1, "Unknown zone" ]
                 elif cmd[0] == "zone" and cmd[1] == "list":
                     answer["result"]     = list(self.config.zones.keys())
                 elif len(cmd) > 1 and cmd[1] == "shutdown":