Skip to content

Commit e091a07

Browse files
authored
Merge pull request #229 from tencentyun/feature_annexwu_7ca2d10b
Feature annexwu 7ca2d10b
1 parent c841e15 commit e091a07

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cos-nodejs-sdk-v5",
3-
"version": "2.16.0-beta.5",
3+
"version": "2.16.0-beta.6",
44
"description": "cos nodejs sdk v5",
55
"main": "index.js",
66
"types": "index.d.ts",

sdk/base.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,27 @@ function getBucketPolicy(params, callback) {
582582
return callback(util.error(err, { ErrorStatus: 'Method Not Allowed' }));
583583
}
584584
if (err.statusCode && err.statusCode === 404) {
585+
/**
586+
* 兼容 New COS 404 错误
587+
*/
588+
try {
589+
if (err
590+
&& err.error
591+
&& err.error.Code
592+
&& (err.error.Code === 'NoSuchPolicy' || err.error.Code === 'NoSuchPolicyVersion')
593+
) {
594+
err.code = '404';
595+
err.message = 'Policy Not found';
596+
err.error.code = '404';
597+
err.error.message = 'Policy Not found';
598+
err.error.statusCode = err.statusCode;
599+
err.error.headers = err.headers;
600+
err.error.url = err.url;
601+
err.error.method = err.method;
602+
err.error.ErrorStatus = 'Policy Not Found';
603+
}
604+
} catch (error) {
605+
}
585606
return callback(util.error(err, { ErrorStatus: 'Policy Not Found' }));
586607
}
587608
return callback(err);

0 commit comments

Comments
 (0)