Reputation: 4377
I'm using the simpleUpload.js script. I'm trying to customize the error messages. The documentation says that:
The type of error can be accessed using error.name and its message at error.message
Given the following callback:
error: function(error){
//upload failed
$('#progress').html("Failure!<br>" + error.name + ": " + error.message);
}
as explained in the docs, one of the possible errors is 'InvalidFileExtensionError' which is returned by error.name
while the relative message is given by error.message
Now I would like to change the text of error.message
but I don't understand how to 'associate' error.name
with error.message
and set the new message. Kind of:
if error.name = "InvalidFileExtensionError" then error.message = "Bad extension"
Upvotes: 1
Views: 43
Reputation: 22158
You can make an object of names with your new values like this
var obj = {"InvalidFileExtensionError": "Bad extension",
"otherError" :"other message" };
And then access like this
obj[error.name]
Upvotes: 2