1
2
3 """
4 Provides some base exception classes.
5 """
6
7 __docformat__ = "restructuredtext en"
8
9
10
11
12
13 __all__ = ['ExceptionWithMessage']
20 """
21 Useful base class for exceptions that have a single exception message
22 argument. Among other things, this method provides a reasonable default
23 ``__str__()`` method.
24
25 Usage:
26
27 .. python::
28
29 from grizzled.exception import ExceptionWithMessage
30
31 class MyException(ExceptionWithMessage):
32 def __init__(self, msg):
33 ExceptionWithMessage.__init__(self, msg)
34 """
36 """
37 Create a new exception.
38
39 @type errorMessage: string
40 @param errorMessage: the error message
41 """
42 self.__message = errorMessage
43
44 @property
46 """
47 The message stored with this object.
48 """
49 return self.__message
50
52 return '%s: %s' % (self.__class__.__name__, self.__message)
53