I am trying to use the try-catch
statements to handle the errors from XMLHTTPRequest
, like below:
var xhr = new XMLHttpRequest();
xhr.open('POST', someurl, true);
try{
xhr.sendMultipart(object);
}
catch(err){
error_handle_function();
}
When there was a 401 error thrown by xhr.sendMultipart
, the error_handle_function
was not called. Any idea how to fix this?
Thanks!