Skip to content

Commit

Permalink
chore: fix remote error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Nora Söderlund committed Feb 3, 2024
1 parent 008f7f7 commit 7747c41
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/wrangler/src/dev/remote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import type {
CfPreviewToken,
} from "./create-worker-preview";
import type { EsbuildBundle } from "./use-esbuild";
import type { FetchError } from "../cfetch";
import type { ParseError } from "../parse";

interface RemoteProps {
name: string | undefined;
Expand Down Expand Up @@ -676,19 +676,19 @@ function ChooseAccount(props: {
* messages, does not perform any logic other than logging errors.
* @returns if the error was handled or not
*/
function handleUserFriendlyError(error: FetchError, accountId?: string) {
function handleUserFriendlyError(error: ParseError, accountId?: string) {

Check warning on line 679 in packages/wrangler/src/dev/remote.tsx

View check run for this annotation

Codecov / codecov/patch

packages/wrangler/src/dev/remote.tsx#L679

Added line #L679 was not covered by tests
// simulate aborts as handled errors by this function, but don't
// log anything
if ((error.code as unknown as string) === "ABORT_ERR") {
if ((error as unknown as { code: string }).code === "ABORT_ERR") {
return true;

Check warning on line 683 in packages/wrangler/src/dev/remote.tsx

View check run for this annotation

Codecov / codecov/patch

packages/wrangler/src/dev/remote.tsx#L683

Added line #L683 was not covered by tests
}

switch(error.code) {
switch((error as unknown as { code: number }).code) {
// code 10021 is a validation error
case 10021: {

Check warning on line 688 in packages/wrangler/src/dev/remote.tsx

View check run for this annotation

Codecov / codecov/patch

packages/wrangler/src/dev/remote.tsx#L688

Added line #L688 was not covered by tests
// if it is the following message, give a more user friendly
// error, otherwise do not handle this error in this function
if(error.message === "binding DB of type d1 must have a valid `id` specified") {
if(error.notes[0].text === "binding DB of type d1 must have a valid `id` specified [code: 10021]") {
const errorMessage =
"Error: You must use a real database in the preview_database_id configuration.";

Check warning on line 693 in packages/wrangler/src/dev/remote.tsx

View check run for this annotation

Codecov / codecov/patch

packages/wrangler/src/dev/remote.tsx#L693

Added line #L693 was not covered by tests
const solutionMessage =
Expand Down

0 comments on commit 7747c41

Please sign in to comment.