Open lfcgomes opened 7 years ago
Replace your code with this:
var uploadPromise = Upload.http({
url: requestInfo.data.url,
method: 'POST',
headers: headers,
data: file
})
uploadPromise.catch(function(error){
return $q.reject({fileID: requestInfo.data.file.id});
});
return uploadPromise;
There are similar issues like this, only the first call would have the abort()
, progress()
functions registered since they are not standard promise chaining functions.
@danialfarid thanks for your reply. I did what you asked my for, but doesn't work :(
With that code, if the server return an error, the catch
function does not catch it and the error is returned directly to the upload error handler function :\
Hi!
I have a service which returns this
However, I want to catch the error that I'm receiving from the server, and parse it before being returned by the service, because the error, by itself, means nothing to the controllers that call this service.
I tried this:
Controller:
It works. Now the error handler function receives this object. However, with this approach, I'm not able to call file.upload.abort() function anymore, given that it does not exist in the file.upload object . How could I achieve what I want to? Is that possible?
Thanks in advance