From bb4e303b8933be01a844cd364d4dc45b33f4c70b Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Thu, 20 Jan 2022 20:22:38 +0000 Subject: [PATCH] feat: add a link to create a github issue when there is an error. When a (non-yargs) error surfaces to the top level, we know also show a link to Github to encourage the developer to report an issue. --- .changeset/modern-beers-repair.md | 8 +++++ packages/wrangler/src/__tests__/kv.test.ts | 40 ++++++++++++++-------- packages/wrangler/src/index.tsx | 8 ++++- 3 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 .changeset/modern-beers-repair.md diff --git a/.changeset/modern-beers-repair.md b/.changeset/modern-beers-repair.md new file mode 100644 index 000000000000..057194d4d842 --- /dev/null +++ b/.changeset/modern-beers-repair.md @@ -0,0 +1,8 @@ +--- +"wrangler": patch +--- + +feat: add a link to create a github issue when there is an error. + +When a (non-yargs) error surfaces to the top level, +we know also show a link to Github to encourage the developer to report an issue. diff --git a/packages/wrangler/src/__tests__/kv.test.ts b/packages/wrangler/src/__tests__/kv.test.ts index 56a8d5493e69..43389ebb0bc7 100644 --- a/packages/wrangler/src/__tests__/kv.test.ts +++ b/packages/wrangler/src/__tests__/kv.test.ts @@ -649,9 +649,11 @@ describe("wrangler", () => { `kv:key put key value --binding otherBinding` ); expect(stdout).toMatchInlineSnapshot(`""`); - expect(stderr).toMatchInlineSnapshot( - `"A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\"."` - ); + expect(stderr).toMatchInlineSnapshot(` + "A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\". + + If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new." + `); expect(error).toMatchInlineSnapshot( `[Error: A namespace with binding name "otherBinding" was not found in the configured "kv_namespaces".]` ); @@ -668,9 +670,11 @@ describe("wrangler", () => { "kv:key put my-key my-value --binding someBinding" ); expect(stdout).toMatchInlineSnapshot(`""`); - expect(stderr).toMatchInlineSnapshot( - `"someBinding has both a namespace ID and a preview ID. Specify \\"--preview\\" or \\"--preview false\\" to avoid writing data to the wrong namespace."` - ); + expect(stderr).toMatchInlineSnapshot(` + "someBinding has both a namespace ID and a preview ID. Specify \\"--preview\\" or \\"--preview false\\" to avoid writing data to the wrong namespace. + + If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new." + `); expect(error).toMatchInlineSnapshot( `[Error: someBinding has both a namespace ID and a preview ID. Specify "--preview" or "--preview false" to avoid writing data to the wrong namespace.]` ); @@ -814,9 +818,11 @@ describe("wrangler", () => { expect(error).toMatchInlineSnapshot( `[Error: A namespace with binding name "otherBinding" was not found in the configured "kv_namespaces".]` ); - expect(stderr).toMatchInlineSnapshot( - `"A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\"."` - ); + expect(stderr).toMatchInlineSnapshot(` + "A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\". + + If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new." + `); expect(stdout).toMatchInlineSnapshot(`""`); }); }); @@ -1001,9 +1007,11 @@ describe("wrangler", () => { `kv:key get key --binding otherBinding` ); expect(stdout).toMatchInlineSnapshot(`""`); - expect(stderr).toMatchInlineSnapshot( - `"A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\"."` - ); + expect(stderr).toMatchInlineSnapshot(` + "A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\". + + If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new." + `); expect(error).toMatchInlineSnapshot( `[Error: A namespace with binding name "otherBinding" was not found in the configured "kv_namespaces".]` ); @@ -1061,9 +1069,11 @@ describe("wrangler", () => { const { stderr } = await runWrangler( `kv:key delete --binding otherBinding someKey` ); - expect(stderr).toMatchInlineSnapshot( - `"A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\"."` - ); + expect(stderr).toMatchInlineSnapshot(` + "A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\". + + If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new." + `); }); it("should delete a key in a namespace specified by binding name in a given environment", async () => { diff --git a/packages/wrangler/src/index.tsx b/packages/wrangler/src/index.tsx index 53b2dfc45aee..50b824b8d60b 100644 --- a/packages/wrangler/src/index.tsx +++ b/packages/wrangler/src/index.tsx @@ -1911,8 +1911,14 @@ export async function main(argv: string[]): Promise { if (e instanceof CommandLineArgsError) { wrangler.showHelp("error"); console.error(""); // Just adds a bit of space + console.error(e.message); + } else { + console.error(e.message); + console.error(""); // Just adds a bit of space + console.error( + "If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new." + ); } - console.error(e.message); throw e; } }