summaryrefslogtreecommitdiffstats
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:40 +0200
commit6f45de10d7251f4b3da8e28575c535f911c10ac6 (patch)
tree33ba0ef143c5402c9242d0f238c94448c825e5f3
parent0575e680137ef3da1722370ccb595f2758f728a0 (diff)
downloadfreeipa-6f45de10d7251f4b3da8e28575c535f911c10ac6.tar.gz
freeipa-6f45de10d7251f4b3da8e28575c535f911c10ac6.tar.xz
freeipa-6f45de10d7251f4b3da8e28575c535f911c10ac6.zip
support multi-line error messages in exceptions
-rw-r--r--install/ui/ipa.css9
-rw-r--r--install/ui/ipa.js31
-rw-r--r--ipalib/errors.py12
3 files changed, 42 insertions, 10 deletions
diff --git a/install/ui/ipa.css b/install/ui/ipa.css
index bc971dce4..4e51c3051 100644
--- a/install/ui/ipa.css
+++ b/install/ui/ipa.css
@@ -1112,6 +1112,13 @@ table.kerberos-key-status {
background-color: #daa520;
}
+.error-message-hinted {
+ color: red;
+ padding-top: 0.5em;
+ padding-bottom: 0.5em;
+ font-family: monospace;
+}
+
/* ---- Table ---- */
table.scrollable thead {
@@ -1784,4 +1791,4 @@ form#login {
.choice-header {
font-weight: bold;
-} \ No newline at end of file
+}
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 45195bc49..e20d3c08a 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -1419,6 +1419,25 @@ IPA.error_dialog = function(spec) {
that.visible_buttons = spec.visible_buttons || ['retry', 'cancel'];
};
+ that.beautify_message = function(container, message) {
+ var lines = message.split(/\n/g);
+ var line_span;
+ for(var i=0; i<lines.length; i++) {
+ // multi-lined text may contain TAB character as first char of the line
+ // to hint at marking the whole line differently
+ if (lines[i].charAt(0) == '\t') {
+ line_span = $('<p />', {
+ 'class': 'error-message-hinted',
+ text: lines[i].substr(1)
+ }).appendTo(container);
+ } else {
+ line_span = $('<p />', {
+ text: lines[i]
+ }).appendTo(container);
+ }
+ }
+ };
+
that.create = function() {
if (that.error_thrown.url) {
$('<p/>', {
@@ -1426,9 +1445,9 @@ IPA.error_dialog = function(spec) {
}).appendTo(that.container);
}
- $('<p/>', {
- html: that.error_thrown.message
- }).appendTo(that.container);
+ var error_message = $('<div />', {});
+ that.beautify_message(error_message, that.error_thrown.message);
+ error_message.appendTo(that.container);
if(that.errors && that.errors.length > 0) {
//render errors
@@ -1457,9 +1476,9 @@ IPA.error_dialog = function(spec) {
for(var i=0; i < that.errors.length; i++) {
var error = that.errors[i];
if(error.message) {
- var error_div = $('<li />', {
- text: error.message
- }).appendTo(errors_container);
+ var error_div = $('<li />', {});
+ that.beautify_message(error_div, error.message);
+ error_div.appendTo(errors_container);
}
}
diff --git a/ipalib/errors.py b/ipalib/errors.py
index 7bf267290..7f1113200 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)