Commit 877122a4 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#201141 by yched: instead of 'HTTP error 200' messages when a PHP error...

#201141 by yched: instead of 'HTTP error 200' messages when a PHP error occurs, actually display the PHP error message
parent 9bc7c07c
......@@ -85,8 +85,8 @@ Drupal.ahah = function(base, element_settings) {
return ahah.success(response, status);
},
complete: function(response, status) {
if (status == 'error') {
return ahah.error(response.responseText);
if (status == 'error' || status == 'parsererror') {
return ahah.error(response, ahah.url);
}
},
dataType: 'json',
......@@ -194,10 +194,10 @@ Drupal.ahah.prototype.success = function (response, status) {
/**
* Handler for the form redirection error.
*/
Drupal.ahah.prototype.error = function (error) {
alert(Drupal.t('An error occurred:\n\n@error', { '@error': error }));
Drupal.ahah.prototype.error = function (response, uri) {
alert(Drupal.ahahError(response, uri));
// Resore the previous action and target to the form.
element.parent('form').attr( { action: this.form_action, target: this.form_target} );
$(this.element).parent('form').attr( { action: this.form_action, target: this.form_target} );
// Remove the progress element.
if (this.progress.element) {
$(this.progress.element).remove();
......
......@@ -282,7 +282,7 @@ Drupal.ACDB.prototype.search = function (searchString) {
}
},
error: function (xmlhttp) {
alert(Drupal.t("An HTTP error @status occurred. \n@uri", { '@status': xmlhttp.status, '@uri': db.uri }));
alert(Drupal.ahahError(xmlhttp, db.uri));
}
});
}, this.delay);
......
......@@ -246,6 +246,24 @@ Drupal.getSelection = function (element) {
return { 'start': element.selectionStart, 'end': element.selectionEnd };
};
/**
* Build an error message from ahah response.
*/
Drupal.ahahError = function(xmlhttp, uri) {
if (xmlhttp.status == 200) {
if (jQuery.trim($(xmlhttp.responseText).text())) {
var message = Drupal.t("An error occurred. \n@uri\n@text", {'@uri': uri, '@text': xmlhttp.responseText });
}
else {
var message = Drupal.t("An error occurred. \n@uri\n(no information available).", {'@uri': uri, '@text': xmlhttp.responseText });
}
}
else {
var message = Drupal.t("An HTTP error @status occurred. \n@uri", {'@uri': uri, '@status': xmlhttp.status });
}
return message;
}
// Global Killswitch on the <html> element
if (Drupal.jsEnabled) {
// Global Killswitch on the <html> element
......
......@@ -85,7 +85,7 @@ Drupal.progressBar.prototype.sendPing = function () {
pb.timer = setTimeout(function() { pb.sendPing(); }, pb.delay);
},
error: function (xmlhttp) {
pb.displayError(Drupal.t("An HTTP error @status occurred. \n@uri", { '@status': xmlhttp.status, '@uri': pb.uri }));
pb.displayError(Drupal.ahahError(xmlhttp, pb.uri));
}
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment