From 0c6d01997eb66353562d8dde61d805c4758eaafc Mon Sep 17 00:00:00 2001 From: Jonathan Cardenas Date: Tue, 14 Dec 2021 15:17:16 -0800 Subject: [PATCH 1/4] Removing type validation for errors --- .../app-configuration/test/internal/tracingHelpers.spec.ts | 3 --- .../app-configuration/test/public/utils/testHelpers.ts | 7 ------- 2 files changed, 10 deletions(-) diff --git a/sdk/appconfiguration/app-configuration/test/internal/tracingHelpers.spec.ts b/sdk/appconfiguration/app-configuration/test/internal/tracingHelpers.spec.ts index e73df9270121..06c1c2414016 100644 --- a/sdk/appconfiguration/app-configuration/test/internal/tracingHelpers.spec.ts +++ b/sdk/appconfiguration/app-configuration/test/internal/tracingHelpers.spec.ts @@ -92,9 +92,6 @@ describe("tracingHelpers", () => { assert.fail("Exception should have been thrown from `trace` since the inner action threw"); } catch (err) { - if (!(err instanceof Error)) { - throw new Error("Error is not recognized"); - } assert.equal(err.message, "Purposefully thrown error"); } diff --git a/sdk/appconfiguration/app-configuration/test/public/utils/testHelpers.ts b/sdk/appconfiguration/app-configuration/test/public/utils/testHelpers.ts index 621732b5aa6c..2288c40b6728 100644 --- a/sdk/appconfiguration/app-configuration/test/public/utils/testHelpers.ts +++ b/sdk/appconfiguration/app-configuration/test/public/utils/testHelpers.ts @@ -18,7 +18,6 @@ import { import { assert } from "chai"; import { DefaultAzureCredential, TokenCredential } from "@azure/identity"; -import { RestError } from "@azure/core-http"; let connectionStringNotPresentWarning = false; let tokenCredentialsNotPresentWarning = false; @@ -163,9 +162,6 @@ export async function assertThrowsRestError( await testFunction(); assert.fail(`${message}: No error thrown`); } catch (err) { - if (!(err instanceof RestError)) { - throw new Error("Error is not recognized"); - } if (err.name === "RestError") { assert.equal(expectedStatusCode, err.statusCode, message); return err; @@ -185,9 +181,6 @@ export async function assertThrowsAbortError( await testFunction(); assert.fail(`${message}: No error thrown`); } catch (e) { - if (!(e instanceof Error)) { - throw new Error("Error is not recognized"); - } if (isPlaybackMode() && (e.name === "FetchError" || e.name === "AbortError")) { return e; } else { From 29a9554ff6662f4c1598bc7cab559a4e87545f6a Mon Sep 17 00:00:00 2001 From: Harsha Nalluru Date: Wed, 15 Dec 2021 01:07:34 +0000 Subject: [PATCH 2/4] dummy commit From e86297427e2135d0a7c76d200a27d5bdeab19a67 Mon Sep 17 00:00:00 2001 From: Jeremy Meng Date: Fri, 17 Dec 2021 21:19:56 +0000 Subject: [PATCH 3/4] Revert "Removing type validation for errors" This reverts commit 0c6d01997eb66353562d8dde61d805c4758eaafc. --- .../app-configuration/test/internal/tracingHelpers.spec.ts | 3 +++ .../app-configuration/test/public/utils/testHelpers.ts | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/sdk/appconfiguration/app-configuration/test/internal/tracingHelpers.spec.ts b/sdk/appconfiguration/app-configuration/test/internal/tracingHelpers.spec.ts index 06c1c2414016..e73df9270121 100644 --- a/sdk/appconfiguration/app-configuration/test/internal/tracingHelpers.spec.ts +++ b/sdk/appconfiguration/app-configuration/test/internal/tracingHelpers.spec.ts @@ -92,6 +92,9 @@ describe("tracingHelpers", () => { assert.fail("Exception should have been thrown from `trace` since the inner action threw"); } catch (err) { + if (!(err instanceof Error)) { + throw new Error("Error is not recognized"); + } assert.equal(err.message, "Purposefully thrown error"); } diff --git a/sdk/appconfiguration/app-configuration/test/public/utils/testHelpers.ts b/sdk/appconfiguration/app-configuration/test/public/utils/testHelpers.ts index 2288c40b6728..621732b5aa6c 100644 --- a/sdk/appconfiguration/app-configuration/test/public/utils/testHelpers.ts +++ b/sdk/appconfiguration/app-configuration/test/public/utils/testHelpers.ts @@ -18,6 +18,7 @@ import { import { assert } from "chai"; import { DefaultAzureCredential, TokenCredential } from "@azure/identity"; +import { RestError } from "@azure/core-http"; let connectionStringNotPresentWarning = false; let tokenCredentialsNotPresentWarning = false; @@ -162,6 +163,9 @@ export async function assertThrowsRestError( await testFunction(); assert.fail(`${message}: No error thrown`); } catch (err) { + if (!(err instanceof RestError)) { + throw new Error("Error is not recognized"); + } if (err.name === "RestError") { assert.equal(expectedStatusCode, err.statusCode, message); return err; @@ -181,6 +185,9 @@ export async function assertThrowsAbortError( await testFunction(); assert.fail(`${message}: No error thrown`); } catch (e) { + if (!(e instanceof Error)) { + throw new Error("Error is not recognized"); + } if (isPlaybackMode() && (e.name === "FetchError" || e.name === "AbortError")) { return e; } else { From 2c00b986883db16a9d50bc464d9fd0873106517a Mon Sep 17 00:00:00 2001 From: Jeremy Meng Date: Fri, 17 Dec 2021 21:22:06 +0000 Subject: [PATCH 4/4] check for Error instance In min/max testing `instanceof RestError` failed. I suspect that the RestError type and the instance are from two different versions of core-http. --- .../app-configuration/test/public/utils/testHelpers.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/appconfiguration/app-configuration/test/public/utils/testHelpers.ts b/sdk/appconfiguration/app-configuration/test/public/utils/testHelpers.ts index 621732b5aa6c..0b143d59669c 100644 --- a/sdk/appconfiguration/app-configuration/test/public/utils/testHelpers.ts +++ b/sdk/appconfiguration/app-configuration/test/public/utils/testHelpers.ts @@ -163,11 +163,12 @@ export async function assertThrowsRestError( await testFunction(); assert.fail(`${message}: No error thrown`); } catch (err) { - if (!(err instanceof RestError)) { + if (!(err instanceof Error)) { throw new Error("Error is not recognized"); } if (err.name === "RestError") { - assert.equal(expectedStatusCode, err.statusCode, message); + const restError = err as RestError; + assert.equal(expectedStatusCode, restError.statusCode, message); return err; }