[checkmk-commits] 3348 FIX Improved error handling when trying to edit not existing rules/ rule packs

Lars Michelsen lm at mathias-kettner.de
Tue Mar 29 15:24:59 CEST 2016


Module: check_mk
Branch: master
Commit: d973bf4cf673aaba44951a815253201786f1f751
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d973bf4cf673aaba44951a815253201786f1f751

Author: Lars Michelsen <lm at mathias-kettner.de>
Date:   Tue Mar 29 15:24:41 2016 +0200

3348 FIX Improved error handling when trying to edit not existing rules/rule packs

---

 .werks/3348                           |   10 ++++++++++
 ChangeLog                             |    1 +
 mkeventd/web/plugins/wato/mkeventd.py |   11 +++++++++--
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/.werks/3348 b/.werks/3348
new file mode 100644
index 0000000..8c3a203
--- /dev/null
+++ b/.werks/3348
@@ -0,0 +1,10 @@
+Title: Improved error handling when trying to edit not existing rules/rule packs
+Level: 1
+Component: ec
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1459257862
+
+
diff --git a/ChangeLog b/ChangeLog
index 457cd8b..aa5d42f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -206,6 +206,7 @@
     * 3058 FIX: Event Console is now allowing non loadable MIB modules on startup...
     * 3097 FIX: mkeventd: fixed crash with non-descriptive error message if mibs couldn't be loaded
     * 3335 FIX: Improved error handling when requested rule pack does not exist
+    * 3348 FIX: Improved error handling when trying to edit not existing rules/rule packs
 
     Livestatus:
     * 3233 FIX: Fixed shutdown of Nagios core with Livestatus module...
diff --git a/mkeventd/web/plugins/wato/mkeventd.py b/mkeventd/web/plugins/wato/mkeventd.py
index 1c431b6..f6cd62d 100644
--- a/mkeventd/web/plugins/wato/mkeventd.py
+++ b/mkeventd/web/plugins/wato/mkeventd.py
@@ -1369,7 +1369,11 @@ def mode_mkeventd_edit_rule_pack(phase):
         if new:
             return _("Create new rule pack")
         else:
-            return _("Edit rule pack %s" % rule_packs[edit_nr]["id"])
+            try:
+                return _("Edit rule pack %s" % rule_packs[edit_nr]["id"])
+            except IndexError:
+                raise MKUserError("edit", _("The rule pack you are trying to "
+                                            "edit does not exist."))
 
     elif phase == "buttons":
         mkeventd_rules_button()
@@ -1461,7 +1465,10 @@ def mode_mkeventd_edit_rule(phase):
         if new:
             return _("Create new rule")
         else:
-            return _("Edit rule %s" % rules[edit_nr]["id"])
+            try:
+                return _("Edit rule %s" % rules[edit_nr]["id"])
+            except IndexError:
+                raise MKUserError("edit", _("The rule you are trying to edit does not exist."))
 
     elif phase == "buttons":
         home_button()



More information about the checkmk-commits mailing list