From 421a975c0e042a56c12a9894afa38f5785d1fe6d Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 11 Nov 2009 18:47:10 -0800 Subject: Improve error handling. --- modules/gallery/views/simple_uploader.html.php | 44 ++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 'modules/gallery/views') diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index a84a3b00..8133f6c2 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -30,11 +30,43 @@ return true; }, onComplete: function(event, queueID, fileObj, response, data) { - $("#g-add-photos-status tbody").append( - "" + fileObj.name + "" + - Math.ceil(fileObj.size / 1000) + " KB" + "" + Math.floor(data.speed) + " KB/s "); + // @todo handle a response of "Error: xxxx" as an error + var re = /^error: (.*)$/i; + var msg = re.exec(response); + if (msg) { + $("#g-add-photos-status ul").append( + "
  • " + fileObj.name + " - " + msg[1] + "
  • "); + } else { + $("#g-add-photos-status ul").append( + "
  • " + fileObj.name + "
  • "); + } return true; }, + + onError: function(event, queueID, fileObj, errorObj) { + var msg = " - "; + if (errorObj.type == "HTTP") { + if (errorObj.info == "500") { + msg += "Error occurred processing the file"; + // Server error - check server logs + } else if (errorObj.info == "404") { + msg += "The upload script was not found."; + // Server script not found + } else { + // Server Error: status: errorObj.info + msg += "Error occurred communication with the server, status: " + errorObj.info; + } + } else if (errorObj.type == "File Size") { + var sizelimit = $("#g-uploadify").uploadifySettings(sizeLimit); + msg += fileObj.name+' '+errorObj.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB'; + } else { + msg += "Error occurred communication with the server, error " + errorObj.type + ": " + errorObj.info; + } + $("#g-add-photos-status ul").append( + "
  • " + fileObj.name + msg + "
  • "); + $("#g-uploadify" + queueID).remove(); + //return false; + }, onSelect: function(event) { if ($("#g-upload-cancel-all").hasClass("ui-state-disabled")) { $("#g-upload-cancel-all") @@ -79,10 +111,8 @@
    - - - -
    +
    -- cgit v1.2.3