Handling exceptions in http.post (for SSL errors)
This commit is contained in:
parent
fba9bd3e5f
commit
fb2a80fc14
@ -197,10 +197,16 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
|
|||||||
resultArray = resultArray.buffer;
|
resultArray = resultArray.buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $http.post('http://' + MtpDcConfigurator.chooseServer(dcID) + '/apiw1', resultArray, {
|
var requestPromise;
|
||||||
responseType: 'arraybuffer',
|
try {
|
||||||
transformRequest: null
|
requestPromise = $http.post('http://' + MtpDcConfigurator.chooseServer(dcID) + '/apiw1', resultArray, {
|
||||||
}).then(
|
responseType: 'arraybuffer',
|
||||||
|
transformRequest: null
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
requestPromise = $q.reject(e);
|
||||||
|
}
|
||||||
|
return requestPromise.then(
|
||||||
function (result) {
|
function (result) {
|
||||||
if (!result.data || !result.data.byteLength) {
|
if (!result.data || !result.data.byteLength) {
|
||||||
return $q.reject({code: 406, type: 'NETWORK_BAD_RESPONSE'});
|
return $q.reject({code: 406, type: 'NETWORK_BAD_RESPONSE'});
|
||||||
@ -1119,10 +1125,16 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
|
|||||||
resultArray = resultArray.buffer;
|
resultArray = resultArray.buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $http.post('http://' + MtpDcConfigurator.chooseServer(self.dcID) + '/apiw1', resultArray, {
|
var requestPromise;
|
||||||
responseType: 'arraybuffer',
|
try {
|
||||||
transformRequest: null
|
requestPromise = $http.post('http://' + MtpDcConfigurator.chooseServer(self.dcID) + '/apiw1', resultArray, {
|
||||||
}).then(
|
responseType: 'arraybuffer',
|
||||||
|
transformRequest: null
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
requestPromise = $q.reject(e);
|
||||||
|
}
|
||||||
|
return requestPromise.then(
|
||||||
function (result) {
|
function (result) {
|
||||||
if (!result.data || !result.data.byteLength) {
|
if (!result.data || !result.data.byteLength) {
|
||||||
return $q.reject({code: 406, type: 'NETWORK_BAD_RESPONSE'});
|
return $q.reject({code: 406, type: 'NETWORK_BAD_RESPONSE'});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user