Skip to content

Commit 44f3559

Browse files
committed
chore(release): v1.5.3
1 parent 7472f00 commit 44f3559

File tree

10 files changed

+101
-98
lines changed

10 files changed

+101
-98
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "leancloud-storage",
3-
"version": "1.5.2",
3+
"version": "1.5.3",
44
"homepage": "https://github.com/leancloud/javascript-sdk",
55
"authors": [
66
"LeanCloud <support@leancloud.rocks>"

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.5.3 (2016-12-02)
2+
* 修复了请求失败的情况下捕获的 Error(code = -1) 没有 message 的问题
3+
14
## 1.5.2 (2016-11-10)
25
* 修复了在 React Native 中调用 `AV.setProduction` 方法导致 React Native 异常的问题
36

dist/av-es6.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10524,37 +10524,37 @@ const cacheServerURL = (serverURL, ttl) => {
1052410524
};
1052510525

1052610526
// handle AV._request Error
10527-
const handleError = (res) => {
10528-
const promise = new AVPromise();
10529-
/**
10530-
When API request need to redirect to the right location,
10531-
can't use browser redirect by http status 307, as the reason of CORS,
10532-
so API server response http status 410 and the param "location" for this case.
10533-
*/
10534-
if (res.statusCode === 410) {
10535-
cacheServerURL(res.response.api_server, res.response.ttl).then(() => {
10536-
promise.resolve(res.response.location);
10537-
}).catch((error) => {
10538-
promise.reject(error);
10539-
});
10540-
} else {
10541-
let errorJSON = { code: -1, error: res.responseText };
10542-
if (res.response && res.response.code) {
10543-
errorJSON = res.response;
10544-
} else if (res.responseText) {
10545-
try {
10546-
errorJSON = JSON.parse(res.responseText);
10547-
} catch (e) {
10548-
// If we fail to parse the error text, that's okay.
10527+
const handleError = (error) => {
10528+
return new AVPromise((resolve, reject) => {
10529+
/**
10530+
When API request need to redirect to the right location,
10531+
can't use browser redirect by http status 307, as the reason of CORS,
10532+
so API server response http status 410 and the param "location" for this case.
10533+
*/
10534+
if (error.statusCode === 410) {
10535+
cacheServerURL(error.response.api_server, error.response.ttl).then(() => {
10536+
resolve(error.response.location);
10537+
}).catch(reject);
10538+
} else {
10539+
let errorJSON = {
10540+
code: error.code || -1,
10541+
error: error.message || error.responseText
10542+
};
10543+
if (error.response && error.response.code) {
10544+
errorJSON = error.response;
10545+
} else if (error.responseText) {
10546+
try {
10547+
errorJSON = JSON.parse(error.responseText);
10548+
} catch (e) {
10549+
// If we fail to parse the error text, that's okay.
10550+
}
1054910551
}
10550-
}
1055110552

10552-
// Transform the error into an instance of AVError by trying to parse
10553-
// the error string as JSON.
10554-
const error = new AVError(errorJSON.code, errorJSON.error);
10555-
promise.reject(error);
10556-
}
10557-
return promise;
10553+
// Transform the error into an instance of AVError by trying to parse
10554+
// the error string as JSON.
10555+
reject(new AVError(errorJSON.code, errorJSON.error));
10556+
}
10557+
});
1055810558
};
1055910559

1056010560
const setServerUrl = (serverURL) => {
@@ -12959,7 +12959,7 @@ const init = (AV) => {
1295912959
*/
1296012960
AV._getAVPath = function(path) {
1296112961
if (!AV.applicationId) {
12962-
throw "You need to call AV.initialize before using AV.";
12962+
throw new Error('You need to call AV.init() before using AV.');
1296312963
}
1296412964
if (!path) {
1296512965
path = "";
@@ -13302,7 +13302,7 @@ module.exports = {
1330213302
* Each engineer has a duty to keep the code elegant
1330313303
**/
1330413304

13305-
module.exports = 'js1.5.2';
13305+
module.exports = 'js1.5.3';
1330613306

1330713307
},{}]},{},[27])(27)
1330813308
});

dist/av-min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/av.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10398,37 +10398,37 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1039810398
};
1039910399

1040010400
// handle AV._request Error
10401-
var handleError = function handleError(res) {
10402-
var promise = new AVPromise();
10403-
/**
10404-
When API request need to redirect to the right location,
10405-
can't use browser redirect by http status 307, as the reason of CORS,
10406-
so API server response http status 410 and the param "location" for this case.
10407-
*/
10408-
if (res.statusCode === 410) {
10409-
cacheServerURL(res.response.api_server, res.response.ttl).then(function () {
10410-
promise.resolve(res.response.location);
10411-
}).catch(function (error) {
10412-
promise.reject(error);
10413-
});
10414-
} else {
10415-
var errorJSON = { code: -1, error: res.responseText };
10416-
if (res.response && res.response.code) {
10417-
errorJSON = res.response;
10418-
} else if (res.responseText) {
10419-
try {
10420-
errorJSON = JSON.parse(res.responseText);
10421-
} catch (e) {
10422-
// If we fail to parse the error text, that's okay.
10401+
var handleError = function handleError(error) {
10402+
return new AVPromise(function (resolve, reject) {
10403+
/**
10404+
When API request need to redirect to the right location,
10405+
can't use browser redirect by http status 307, as the reason of CORS,
10406+
so API server response http status 410 and the param "location" for this case.
10407+
*/
10408+
if (error.statusCode === 410) {
10409+
cacheServerURL(error.response.api_server, error.response.ttl).then(function () {
10410+
resolve(error.response.location);
10411+
}).catch(reject);
10412+
} else {
10413+
var errorJSON = {
10414+
code: error.code || -1,
10415+
error: error.message || error.responseText
10416+
};
10417+
if (error.response && error.response.code) {
10418+
errorJSON = error.response;
10419+
} else if (error.responseText) {
10420+
try {
10421+
errorJSON = JSON.parse(error.responseText);
10422+
} catch (e) {
10423+
// If we fail to parse the error text, that's okay.
10424+
}
1042310425
}
10424-
}
1042510426

10426-
// Transform the error into an instance of AVError by trying to parse
10427-
// the error string as JSON.
10428-
var error = new AVError(errorJSON.code, errorJSON.error);
10429-
promise.reject(error);
10430-
}
10431-
return promise;
10427+
// Transform the error into an instance of AVError by trying to parse
10428+
// the error string as JSON.
10429+
reject(new AVError(errorJSON.code, errorJSON.error));
10430+
}
10431+
});
1043210432
};
1043310433

1043410434
var setServerUrl = function setServerUrl(serverURL) {
@@ -12775,7 +12775,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1277512775
*/
1277612776
AV._getAVPath = function (path) {
1277712777
if (!AV.applicationId) {
12778-
throw "You need to call AV.initialize before using AV.";
12778+
throw new Error('You need to call AV.init() before using AV.');
1277912779
}
1278012780
if (!path) {
1278112781
path = "";
@@ -13106,6 +13106,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1310613106
* Each engineer has a duty to keep the code elegant
1310713107
**/
1310813108

13109-
module.exports = 'js1.5.2';
13109+
module.exports = 'js1.5.3';
1311013110
}, {}] }, {}, [27])(27);
1311113111
});

dist/node/request.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -175,37 +175,37 @@ var cacheServerURL = function cacheServerURL(serverURL, ttl) {
175175
};
176176

177177
// handle AV._request Error
178-
var handleError = function handleError(res) {
179-
var promise = new AVPromise();
180-
/**
181-
When API request need to redirect to the right location,
182-
can't use browser redirect by http status 307, as the reason of CORS,
183-
so API server response http status 410 and the param "location" for this case.
184-
*/
185-
if (res.statusCode === 410) {
186-
cacheServerURL(res.response.api_server, res.response.ttl).then(function () {
187-
promise.resolve(res.response.location);
188-
}).catch(function (error) {
189-
promise.reject(error);
190-
});
191-
} else {
192-
var errorJSON = { code: -1, error: res.responseText };
193-
if (res.response && res.response.code) {
194-
errorJSON = res.response;
195-
} else if (res.responseText) {
196-
try {
197-
errorJSON = JSON.parse(res.responseText);
198-
} catch (e) {
199-
// If we fail to parse the error text, that's okay.
178+
var handleError = function handleError(error) {
179+
return new AVPromise(function (resolve, reject) {
180+
/**
181+
When API request need to redirect to the right location,
182+
can't use browser redirect by http status 307, as the reason of CORS,
183+
so API server response http status 410 and the param "location" for this case.
184+
*/
185+
if (error.statusCode === 410) {
186+
cacheServerURL(error.response.api_server, error.response.ttl).then(function () {
187+
resolve(error.response.location);
188+
}).catch(reject);
189+
} else {
190+
var errorJSON = {
191+
code: error.code || -1,
192+
error: error.message || error.responseText
193+
};
194+
if (error.response && error.response.code) {
195+
errorJSON = error.response;
196+
} else if (error.responseText) {
197+
try {
198+
errorJSON = JSON.parse(error.responseText);
199+
} catch (e) {
200+
// If we fail to parse the error text, that's okay.
201+
}
200202
}
201-
}
202203

203-
// Transform the error into an instance of AVError by trying to parse
204-
// the error string as JSON.
205-
var error = new AVError(errorJSON.code, errorJSON.error);
206-
promise.reject(error);
207-
}
208-
return promise;
204+
// Transform the error into an instance of AVError by trying to parse
205+
// the error string as JSON.
206+
reject(new AVError(errorJSON.code, errorJSON.error));
207+
}
208+
});
209209
};
210210

211211
var setServerUrl = function setServerUrl(serverURL) {

dist/node/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ var init = function init(AV) {
234234
*/
235235
AV._getAVPath = function (path) {
236236
if (!AV.applicationId) {
237-
throw "You need to call AV.initialize before using AV.";
237+
throw new Error('You need to call AV.init() before using AV.');
238238
}
239239
if (!path) {
240240
path = "";

dist/node/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
* Each engineer has a duty to keep the code elegant
66
**/
77

8-
module.exports = 'js1.5.2';
8+
module.exports = 'js1.5.3';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "leancloud-storage",
3-
"version": "1.5.2",
3+
"version": "1.5.3",
44
"main": "./dist/node/index.js",
55
"description": "LeanCloud JavaScript SDK.",
66
"repository": {

src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
* Each engineer has a duty to keep the code elegant
44
**/
55

6-
module.exports = 'js1.5.2';
6+
module.exports = 'js1.5.3';

0 commit comments

Comments
 (0)