diff --git a/packages/fx-core/src/component/driver/aad/create.ts b/packages/fx-core/src/component/driver/aad/create.ts index 0d21ece7ff..416ef61c91 100644 --- a/packages/fx-core/src/component/driver/aad/create.ts +++ b/packages/fx-core/src/component/driver/aad/create.ts @@ -160,12 +160,12 @@ export class CreateAadAppDriver implements StepDriver { ); if (error.response!.status >= 400 && error.response!.status < 500) { return { - result: err(new UnhandledUserError(error as Error, actionName, helpLink)), + result: err(new UnhandledUserError(new Error(message), actionName, helpLink)), summaries: summaries, }; } else { return { - result: err(new UnhandledError(error as Error, actionName)), + result: err(new UnhandledError(new Error(message), actionName)), summaries: summaries, }; } diff --git a/packages/fx-core/src/component/driver/aad/update.ts b/packages/fx-core/src/component/driver/aad/update.ts index 17265b2841..a07b557241 100644 --- a/packages/fx-core/src/component/driver/aad/update.ts +++ b/packages/fx-core/src/component/driver/aad/update.ts @@ -117,12 +117,12 @@ export class UpdateAadAppDriver implements StepDriver { ); if (error.response!.status >= 400 && error.response!.status < 500) { return { - result: err(new UnhandledUserError(error as Error, actionName, helpLink)), + result: err(new UnhandledUserError(new Error(message), actionName, helpLink)), summaries: summaries, }; } else { return { - result: err(new UnhandledError(error as Error, actionName)), + result: err(new UnhandledError(new Error(message), actionName)), summaries: summaries, }; } diff --git a/packages/fx-core/tests/component/driver/aad/create.test.ts b/packages/fx-core/tests/component/driver/aad/create.test.ts index 7ec7077777..fe42e684df 100644 --- a/packages/fx-core/tests/component/driver/aad/create.test.ts +++ b/packages/fx-core/tests/component/driver/aad/create.test.ts @@ -327,7 +327,9 @@ describe("aadAppCreate", async () => { expect(result.result._unsafeUnwrapErr()) .is.instanceOf(UnhandledUserError) .and.has.property("message") - .and.contains("An unexpected error has occurred while performing the aadApp/create task"); + .and.equals( + 'An unexpected error has occurred while performing the aadApp/create task. The reason for this error is: {"error":{"code":"Request_BadRequest","message":"Invalid value specified for property \'displayName\' of resource \'Application\'."}}. Welcome to report this issue by clicking on the provided "Issue Link", so that we can investigate and resolve the problem as soon as possible.' + ); }); it("should throw system error when AadAppClient failed with non 4xx error", async () => { @@ -354,7 +356,9 @@ describe("aadAppCreate", async () => { expect(result.result._unsafeUnwrapErr()) .is.instanceOf(UnhandledError) .and.has.property("message") - .and.contains("An unexpected error has occurred while performing the aadApp/create task"); + .and.equals( + 'An unexpected error has occurred while performing the aadApp/create task. The reason for this error is: {"error":{"code":"InternalServerError","message":"Internal server error"}}. Welcome to report this issue by clicking on the provided "Issue Link", so that we can investigate and resolve the problem as soon as possible.' + ); }); it("should send telemetries when success", async () => { diff --git a/packages/fx-core/tests/component/driver/aad/update.test.ts b/packages/fx-core/tests/component/driver/aad/update.test.ts index 55750e34ed..d522c3da28 100644 --- a/packages/fx-core/tests/component/driver/aad/update.test.ts +++ b/packages/fx-core/tests/component/driver/aad/update.test.ts @@ -508,7 +508,9 @@ describe("aadAppUpdate", async () => { expect(result.result._unsafeUnwrapErr()) .is.instanceOf(UnhandledUserError) .and.property("message") - .contain("An unexpected error has occurred while performing the aadApp/update task"); + .equals( + 'An unexpected error has occurred while performing the aadApp/update task. The reason for this error is: {"error":{"code":"Request_BadRequest","message":"Invalid value specified for property \'displayName\' of resource \'Application\'."}}. Welcome to report this issue by clicking on the provided "Issue Link", so that we can investigate and resolve the problem as soon as possible.' + ); }); it("should throw system error when AadAppClient failed with non 4xx error", async () => { @@ -540,7 +542,9 @@ describe("aadAppUpdate", async () => { expect(result.result._unsafeUnwrapErr()) .is.instanceOf(UnhandledError) .and.property("message") - .contain("An unexpected error has occurred while performing the aadApp/update task"); + .equals( + 'An unexpected error has occurred while performing the aadApp/update task. The reason for this error is: {"error":{"code":"InternalServerError","message":"Internal server error"}}. Welcome to report this issue by clicking on the provided "Issue Link", so that we can investigate and resolve the problem as soon as possible.' + ); }); it("should send telemetries when success", async () => {