Module: check_mk
Branch: master
Commit: 6b7cefdbbe5d98b8c228774eee0f54597ed06631
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6b7cefdbbe5d98…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Apr 16 17:01:00 2018 +0200
BI: Improved error handling of not existant rule packs
Change-Id: Id93bdf3bc5b08d059f840d12d9059582e551e05a
---
web/plugins/wato/bi.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/web/plugins/wato/bi.py b/web/plugins/wato/bi.py
index da9ef51..88bbd64 100644
--- a/web/plugins/wato/bi.py
+++ b/web/plugins/wato/bi.py
@@ -77,9 +77,10 @@ class ModeBI(WatoMode):
# Most modes need a pack as context
if html.has_var("pack"):
self._pack_id = html.var("pack")
- if self._pack_id not in self._packs:
- raise MKGeneralException(_("The BI pack '%s' does not
exist.") % html.attrencode(self._pack_id))
- self._pack = self._packs[self._pack_id]
+ try:
+ self._pack = self._packs[self._pack_id]
+ except KeyError:
+ raise MKUserError("pack", _("This BI pack does not
exist."))
else:
self._pack_id = None
self._pack = None
@@ -963,7 +964,11 @@ class ModeBIPacks(ModeBI):
def action(self):
if config.user.may("wato.bi_admin") and
html.has_var("_delete"):
pack_id = html.var("_delete")
- pack = self._packs[pack_id]
+ try:
+ pack = self._packs[pack_id]
+ except KeyError:
+ raise MKUserError("_delete", _("This BI pack does not
exist."))
+
if pack["rules"]:
raise MKUserError(None, _("You cannot delete this pack. It contains
<b>%d</b> rules.") % len(pack["rules"]))
c = wato_confirm(_("Confirm BI pack deletion"),