-
Notifications
You must be signed in to change notification settings - Fork 789
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: throw helpful error if email validation required (#4592)
- Loading branch information
Showing
4 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
fix: throw helpful error if email validation required | ||
|
||
Previously, Wrangler would display the raw API error message and code if email validation was required during `wrangler deploy`. This change ensures a helpful error message is displayed instead, prompting users to check their emails or visit the dashboard for a verification link. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ParseError } from "../parse"; | ||
|
||
export interface FetchError { | ||
code: number; | ||
message: string; | ||
error_chain?: FetchError[]; | ||
} | ||
|
||
function buildDetailedError(message: string, ...extra: string[]) { | ||
return new ParseError({ | ||
text: message, | ||
notes: extra.map((text) => ({ text })), | ||
}); | ||
} | ||
|
||
export function maybeThrowFriendlyError(error: FetchError) { | ||
if (error.message === "workers.api.error.email_verification_required") { | ||
throw buildDetailedError( | ||
"Please verify your account's email address and try again.", | ||
"Check your email for a verification link, or login to https://dash.cloudflare.com and request a new one." | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters