mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
support multi-line error messages in exceptions
This commit is contained in:
committed by
Martin Kosek
parent
0575e68013
commit
6f45de10d7
@@ -1112,6 +1112,13 @@ table.kerberos-key-status {
|
|||||||
background-color: #daa520;
|
background-color: #daa520;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error-message-hinted {
|
||||||
|
color: red;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
padding-bottom: 0.5em;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
|
||||||
/* ---- Table ---- */
|
/* ---- Table ---- */
|
||||||
|
|
||||||
table.scrollable thead {
|
table.scrollable thead {
|
||||||
|
|||||||
@@ -1419,6 +1419,25 @@ IPA.error_dialog = function(spec) {
|
|||||||
that.visible_buttons = spec.visible_buttons || ['retry', 'cancel'];
|
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() {
|
that.create = function() {
|
||||||
if (that.error_thrown.url) {
|
if (that.error_thrown.url) {
|
||||||
$('<p/>', {
|
$('<p/>', {
|
||||||
@@ -1426,9 +1445,9 @@ IPA.error_dialog = function(spec) {
|
|||||||
}).appendTo(that.container);
|
}).appendTo(that.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('<p/>', {
|
var error_message = $('<div />', {});
|
||||||
html: that.error_thrown.message
|
that.beautify_message(error_message, that.error_thrown.message);
|
||||||
}).appendTo(that.container);
|
error_message.appendTo(that.container);
|
||||||
|
|
||||||
if(that.errors && that.errors.length > 0) {
|
if(that.errors && that.errors.length > 0) {
|
||||||
//render errors
|
//render errors
|
||||||
@@ -1457,9 +1476,9 @@ IPA.error_dialog = function(spec) {
|
|||||||
for(var i=0; i < that.errors.length; i++) {
|
for(var i=0; i < that.errors.length; i++) {
|
||||||
var error = that.errors[i];
|
var error = that.errors[i];
|
||||||
if(error.message) {
|
if(error.message) {
|
||||||
var error_div = $('<li />', {
|
var error_div = $('<li />', {});
|
||||||
text: error.message
|
that.beautify_message(error_div, error.message);
|
||||||
}).appendTo(errors_container);
|
error_div.appendTo(errors_container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -265,11 +265,17 @@ class PublicError(StandardError):
|
|||||||
)
|
)
|
||||||
self.format = format
|
self.format = format
|
||||||
self.forwarded = False
|
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):
|
if isinstance(self.format, basestring):
|
||||||
self.strerror = ugettext(self.format) % kw
|
self.strerror = ugettext(self.format) % kwargs
|
||||||
else:
|
else:
|
||||||
self.strerror = self.format % kw
|
self.strerror = self.format % kwargs
|
||||||
else:
|
else:
|
||||||
if isinstance(message, (Gettext, NGettext)):
|
if isinstance(message, (Gettext, NGettext)):
|
||||||
message = unicode(message)
|
message = unicode(message)
|
||||||
|
|||||||
Reference in New Issue
Block a user