Skip to content

Commit 6ee9a8d

Browse files
committed
feat/supportNewCos (merge request !31)
Squash merge branch 'feat/supportNewCos' into 'master' 兼容 NewCOS 的 GetBucketPolicy 的格式。 <img width="" src="/uploads/9BA3CEA857C044D1871DBBDCCB6A8F1E/image.png" alt="image.png" /> TAPD: --story=125742958
1 parent 5040217 commit 6ee9a8d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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)