2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2016 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 from cmk
.utils
.i18n
import _
30 # never used directly in the code. Just some wrapper to make all of our
31 # exceptions handleable with one call
32 class MKException(Exception):
33 # TODO: The comment and the method below are nonsense: If we want unicode,
34 # it is __unicode__'s task. This just seems to be a workaround for incorrect
35 # call sites confusing both kinds of strings. Sometimes returning a unicode
36 # string below just asks for trouble when e.g. this is spliced into a byte
37 # string, and it *is* a byte string when __str__ is called: Splicing into a
38 # unicode string would call __unicode__.
40 # Do not use the Exception() __str__, because it uses str()
41 # to convert the message. We want to keep unicode strings untouched
42 # And don't use self.message, because older python versions don't
43 # have this variable set. self.args[0] seems to be the most portable
46 return self
.args
[0] if self
.args
else ''
49 class MKGeneralException(MKException
):
50 def __init__(self
, reason
):
52 super(MKGeneralException
, self
).__init
__(reason
)
57 def plain_title(self
):
58 return _("General error")
64 # This exception is raises when the current program execution should be
65 # terminated. For example it is raised by the SIGINT signal handler to
66 # propagate the termination up the callstack.
67 # This should be raised in all cases where the program termination is a
68 # "normal" case and no exception handling like printing a stack trace
69 # nor an error message should be done. The program is stopped with
71 class MKTerminate(Exception):
75 # This is raised to print an error message and then end the program.
76 # The program should catch this at top level and end exit the program
77 # with exit code 3, in order to be compatible with monitoring plugin API.
78 class MKBailOut(Exception):
79 def __init__(self
, reason
):
81 super(MKBailOut
, self
).__init
__(reason
)
87 # This exception is raised when a previously configured timeout is reached.
88 # It is used during keepalive mode. It is also used by the automations
89 # which have a timeout set.
90 class MKTimeout(MKException
):