Fixed blank dialog box on internal error.

Previously when an internal error occurs on the server the UI will
display a blank error dialog box. To fix the problem the string
message thrown by Ajax has been converted into an object containing
the error message.

Ticket #1280
This commit is contained in:
Endi S. Dewata 2011-06-03 10:49:42 -05:00 committed by Adam Young
parent 34c5d996d7
commit 403ed477b5

View File

@ -287,13 +287,6 @@ IPA.command = function(spec) {
IPA.hide_activity_icon(); IPA.hide_activity_icon();
if (!error_thrown) {
error_thrown = {
name: xhr.responseText || 'Unknown Error',
message: xhr.statusText || 'Unknown Error'
};
}
if (xhr.status === 401) { if (xhr.status === 401) {
error_thrown = {}; // error_thrown is string error_thrown = {}; // error_thrown is string
error_thrown.name = 'Kerberos ticket no longer valid.'; error_thrown.name = 'Kerberos ticket no longer valid.';
@ -307,6 +300,18 @@ IPA.command = function(spec) {
"<a href='/ipa/config/unauthorized.html'>"+ "<a href='/ipa/config/unauthorized.html'>"+
"follow these directions</a> to configure your browser."; "follow these directions</a> to configure your browser.";
} }
} else if (!error_thrown) {
error_thrown = {
name: xhr.responseText || 'Unknown Error',
message: xhr.statusText || 'Unknown Error'
};
} else if (typeof error_thrown == 'string') {
error_thrown = {
name: error_thrown,
message: error_thrown
};
} }
if (that.retry) { if (that.retry) {
@ -320,13 +325,12 @@ IPA.command = function(spec) {
function success_handler(data, text_status, xhr) { function success_handler(data, text_status, xhr) {
if (!data) { if (!data) {
IPA.hide_activity_icon(); // error_handler() calls IPA.hide_activity_icon()
var error_thrown = { error_handler.call(this, xhr, text_status, /* error_thrown */ {
name: 'HTTP Error '+xhr.status, name: 'HTTP Error '+xhr.status,
url: this.url, url: this.url,
message: data ? xhr.statusText : "No response" message: data ? xhr.statusText : 'No response'
}; });
dialog_open.call(this, xhr, text_status, error_thrown);
} else if (data.error) { } else if (data.error) {
// error_handler() calls IPA.hide_activity_icon() // error_handler() calls IPA.hide_activity_icon()