diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2008-01-04 11:53:21 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2008-01-04 11:53:21 +0000 |
commit | 877122a4a14adaac4e8703ae43c96f589804170a (patch) | |
tree | 358e50c9688c08cb39ca78b3274932d0acca7bf3 /misc | |
parent | 9bc7c07cb71efcd941489a3fca7564b8f7709619 (diff) | |
download | brdo-877122a4a14adaac4e8703ae43c96f589804170a.tar.gz brdo-877122a4a14adaac4e8703ae43c96f589804170a.tar.bz2 |
#201141 by yched: instead of 'HTTP error 200' messages when a PHP error occurs, actually display the PHP error message
Diffstat (limited to 'misc')
-rw-r--r-- | misc/ahah.js | 10 | ||||
-rw-r--r-- | misc/autocomplete.js | 2 | ||||
-rw-r--r-- | misc/drupal.js | 18 | ||||
-rw-r--r-- | misc/progress.js | 2 |
4 files changed, 25 insertions, 7 deletions
diff --git a/misc/ahah.js b/misc/ahah.js index acbd4812f..775159d6b 100644 --- a/misc/ahah.js +++ b/misc/ahah.js @@ -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(); diff --git a/misc/autocomplete.js b/misc/autocomplete.js index aa2deb019..4741de727 100644 --- a/misc/autocomplete.js +++ b/misc/autocomplete.js @@ -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); diff --git a/misc/drupal.js b/misc/drupal.js index edf621101..a69d5e16c 100644 --- a/misc/drupal.js +++ b/misc/drupal.js @@ -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 diff --git a/misc/progress.js b/misc/progress.js index 70fa3fad4..4a7ee3cfe 100644 --- a/misc/progress.js +++ b/misc/progress.js @@ -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)); } }); } |