Skip to content

Commit

Permalink
handle NamespaceIdError specially
Browse files Browse the repository at this point in the history
  • Loading branch information
jackluson committed Nov 25, 2024
1 parent 632a7aa commit 8f3f5ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/shared/lib/cloudflare/enum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export enum ErrorCode {
NotFoundRoute = 7003,
AuthenicationError = 10000,
NamespaceIdError = 10011,
}
8 changes: 6 additions & 2 deletions packages/shared/lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ export function checkCloudflareResponse(
if ((res as WriteResponse)?.success) {
callback({ isOk: true, msg: `${scene} success` });
} else {
const isAccountError = res?.errors?.length && res.errors[0].code === ErrorCode.NotFoundRoute;
const cloudFlareErrors = [ErrorCode.NotFoundRoute, ErrorCode.NamespaceIdError, ErrorCode.AuthenicationError];
const isAccountError = res?.errors?.length && cloudFlareErrors.includes(res.errors[0].code);
if (isAccountError) {
callback({
isOk: false,
msg: 'cloudflare account info is incorrect.',
msg:
res.errors[0].code === ErrorCode.NamespaceIdError
? 'cloudflare namespace Id info is incorrect.'
: 'cloudflare account info is incorrect.',
code: MessageErrorCode.CloudflareNotFoundRoute,
result: res,
});
Expand Down

0 comments on commit 8f3f5ea

Please sign in to comment.