Skip to content

Node.js based forum software built for the modern web

better error message if image upload fails, #1052

Baris Soner Usakli83ad454c3ec5
diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js
index 866f8ecdf6..ee833381e6 100644
--- a/public/src/modules/composer.js
+++ b/public/src/modules/composer.js
@@ -604,10 +604,8 @@ define(['taskbar'], function(taskbar) {
clearForm: true,
formData: formData,
error: function(xhr) {
- app.alertError('Error uploading file! ' + xhr.status);
- composer.posts[post_uuid].uploadsInProgress.pop();
+ app.alertError('Error uploading file!\nStatus : ' + xhr.status + '\nMessage : ' + xhr.responseText);
},
-
uploadProgress: function(event, position, total, percent) {
var current = textarea.val();
for(var i=0; i<files.length; ++i) {
@@ -615,7 +613,6 @@ define(['taskbar'], function(taskbar) {
textarea.val(current.replace(re, files[i].name+'](uploading ' + percent + '%)'));
}
},
-
success: function(uploads) {
if(uploads && uploads.length) {
@@ -626,8 +623,11 @@ define(['taskbar'], function(taskbar) {
}
}
- composer.posts[post_uuid].uploadsInProgress.pop();
textarea.focus();
+ },
+ complete: function(xhr, status) {
+ uploadForm[0].reset();
+ composer.posts[post_uuid].uploadsInProgress.pop();
}
});
diff --git a/src/routes/api.js b/src/routes/api.js
index 2693b46597..0ddbc04582 100644
--- a/src/routes/api.js
+++ b/src/routes/api.js
@@ -479,7 +479,7 @@ var path = require('path'),
deleteTempFiles();
if(err) {
- return res.json(500, {message: err.message});
+ return res.json(500, err.message);
}
res.json(200, images);