Skip to content

Commit bec2e5e

Browse files
committed
fix: uniform api error message
1 parent c410339 commit bec2e5e

File tree

10 files changed

+111
-106
lines changed

10 files changed

+111
-106
lines changed

src/modules/apigw/apis.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function apiFactory(actions) {
4141
if (Response.Error.Code.indexOf('ResourceNotFound') === -1) {
4242
throw new TypeError(
4343
`API_APIGW_${action}`,
44-
`${Response.Error.Code}: ${Response.Error.Message}`,
44+
`${Response.Error.Code}: ${Response.Error.Message} ${Response.RequestId}`,
4545
null,
4646
Response.RequestId,
4747
);

src/modules/cam/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ class Cam {
1515
if (res.Response && res.Response.Error) {
1616
throw new TypeError(
1717
`API_CAM_${data.Action}`,
18-
JSON.stringify(res.Response),
18+
`${res.Response.Error.Code}: ${res.Response.Error.Message} ${res.Response.RequestId}`,
1919
null,
2020
res.Response.RequestId,
2121
);
2222
}
2323
return res;
2424
} catch (e) {
25-
throw new TypeError(`API_CAM_${data.Action}`, e.message, e.stack);
25+
throw new TypeError(`API_CAM_${data.Action}`, e.message, e.stack, e.reqId);
2626
}
2727
}
2828

src/modules/cdn/apis.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ function apiFactory(actions) {
3838
if (Response && Response.Error && Response.Error.Code) {
3939
throw new TypeError(
4040
`API_CDN_${action}`,
41-
Response.Error.Message,
41+
`${Response.Error.Code}: ${Response.Error.Message} ${Response.RequestId}`,
4242
null,
4343
Response.RequestId,
4444
);
4545
}
4646
return Response;
4747
} catch (e) {
48-
throw new TypeError(`API_CDN_${action}`, e.message, e.stack);
48+
throw new TypeError(`API_CDN_${action}`, e.message, e.stack, e.reqId);
4949
}
5050
};
5151
});

src/modules/cfs/apis/apis.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function apiFactory(actions) {
2525
if (Response && Response.Error && Response.Error.Code) {
2626
throw new TypeError(
2727
`API_CFS_${action}`,
28-
Response.Error.Message,
28+
`${Response.Error.Code}: ${Response.Error.Message} ${Response.RequestId}`,
2929
null,
3030
Response.RequestId,
3131
);

src/modules/cos/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class Cos {
8282
console.log(`Bucket ${inputs.bucket} already exist.`);
8383
}
8484
} else {
85-
throw new TypeError(`API_COS_headBucket`, 'Could not find this bucket');
85+
throw new TypeError(`API_COS_headBucket`, `Could not find bucket ${inputs.bucket}`);
8686
}
8787
} catch (err) {
8888
throw new TypeError(`API_COS_headBucket`, err.message, err.stack);

src/modules/layer/apis/apis.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function apiFactory(actions) {
2626
if (Response && Response.Error && Response.Error.Code) {
2727
throw new TypeError(
2828
`API_LAYER_${action}`,
29-
Response.Error.Message,
29+
`${Response.Error.Code}: ${Response.Error.Message} ${Response.RequestId}`,
3030
null,
3131
Response.RequestId,
3232
);

src/modules/postgresql/apis.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ function apiFactory(actions) {
2828
if (Response && Response.Error && Response.Error.Code) {
2929
throw new TypeError(
3030
`API_POSTGRESQL_${action}`,
31-
Response.Error.Message,
31+
`${Response.Error.Code}: ${Response.Error.Message} ${Response.RequestId}`,
3232
null,
3333
Response.RequestId,
3434
);
3535
}
3636
return Response;
3737
} catch (e) {
38-
throw new TypeError(`API_POSTGRESQL_${action}`, e.message, e.stack);
38+
throw new TypeError(`API_POSTGRESQL_${action}`, e.message, e.stack, e.reqId);
3939
}
4040
};
4141
});

0 commit comments

Comments
 (0)