summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorAlexander Bokovoy <abokovoy@redhat.com>2012-10-04 15:05:17 +0300
committerMartin Kosek <mkosek@redhat.com>2012-10-09 10:18:51 +0200
commit7ebf72393f441c7958db2b923afee454fb49f9c5 (patch)
treefebbf93d56e3ea76bea96e9ef4264dd72e34eeb1 /ipalib
parent01dba94f4c41cb76eabffaca113c13c5188a268c (diff)
downloadfreeipa.git-7ebf72393f441c7958db2b923afee454fb49f9c5.tar.gz
freeipa.git-7ebf72393f441c7958db2b923afee454fb49f9c5.tar.xz
freeipa.git-7ebf72393f441c7958db2b923afee454fb49f9c5.zip
support multi-line error messages in exceptions
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/errors.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py
index 7bf26729..7f111320 100644
--- a/ipalib/errors.py
+++ b/ipalib/errors.py
@@ -265,11 +265,17 @@ class PublicError(StandardError):
)
self.format = format
self.forwarded = False
- self.msg = self.format % kw
+ def convert_keyword(value):
+ if isinstance(value, list):
+ result=u'\n'.join(map(lambda line: unicode(line), value))
+ return result
+ return value
+ kwargs = dict(map(lambda (k,v): (k, convert_keyword(v)), kw.items()))
+ self.msg = self.format % kwargs
if isinstance(self.format, basestring):
- self.strerror = ugettext(self.format) % kw
+ self.strerror = ugettext(self.format) % kwargs
else:
- self.strerror = self.format % kw
+ self.strerror = self.format % kwargs
else:
if isinstance(message, (Gettext, NGettext)):
message = unicode(message)