summaryrefslogtreecommitdiffstats
path: root/ipalib/errors.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2015-09-18 17:52:10 +0200
committerTomas Babej <tbabej@redhat.com>2015-10-13 14:16:32 +0200
commitb71fd2d3c9573c81a376c420df25a319149c5b7d (patch)
treed3364b1aced9540b4a156c9edae30f5a9a5e0ee0 /ipalib/errors.py
parent905d81f500d40b44c8e7f284af11300057e3d1b7 (diff)
downloadfreeipa-b71fd2d3c9573c81a376c420df25a319149c5b7d.tar.gz
freeipa-b71fd2d3c9573c81a376c420df25a319149c5b7d.tar.xz
freeipa-b71fd2d3c9573c81a376c420df25a319149c5b7d.zip
Add `message` property to IPA's errors and warnings under Python 3
Python 3 removes the "message" attribute from exceptions, in favor of just calling str(). Add it back for IPA's own exception types. Reviewed-By: Tomas Babej <tbabej@redhat.com>
Diffstat (limited to 'ipalib/errors.py')
-rw-r--r--ipalib/errors.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py
index 49b628aad..b82d19949 100644
--- a/ipalib/errors.py
+++ b/ipalib/errors.py
@@ -102,6 +102,8 @@ current block assignments:
- **5100 - 5999** *Reserved for future use*
"""
+import six
+
from ipalib.text import ngettext as ungettext
from ipalib import messages
from ipaplatform.paths import paths
@@ -124,6 +126,11 @@ class PrivateError(Exception):
setattr(self, key, value)
Exception.__init__(self, self.msg)
+ if six.PY3:
+ @property
+ def message(self):
+ return str(self)
+
class SubprocessError(PrivateError):
"""
@@ -251,6 +258,11 @@ class PublicError(Exception):
rval = 1
format = None
+ if six.PY3:
+ @property
+ def message(self):
+ return str(self)
+
class VersionError(PublicError):
"""