From 7b16899351ffde94fa2fd70ec25e1a86ad903cec Mon Sep 17 00:00:00 2001 From: Michael Anstis Date: Tue, 27 Aug 2024 21:03:06 +0100 Subject: [PATCH] AAP-29861: WCA: Handle 'HTTP404: Failed to get remaining capacity' response (#1519) --- src/features/lightspeed/errors.ts | 8 ++++++++ .../lightspeed/utils/handleApiError.test.ts | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/features/lightspeed/errors.ts b/src/features/lightspeed/errors.ts index be73db07e..c4632ec4d 100644 --- a/src/features/lightspeed/errors.ts +++ b/src/features/lightspeed/errors.ts @@ -259,6 +259,14 @@ ERRORS.addError( ), ); +ERRORS.addError( + 418, + new Error( + "error__wca_instance_deleted", + "IBM watsonx Code Assistant instance associated with your Model Id has been deleted. Please contact your administrator.", + ), +); + ERRORS.addError( 500, new Error( diff --git a/test/units/lightspeed/utils/handleApiError.test.ts b/test/units/lightspeed/utils/handleApiError.test.ts index 5ad5fdc62..ca4d7d359 100644 --- a/test/units/lightspeed/utils/handleApiError.test.ts +++ b/test/units/lightspeed/utils/handleApiError.test.ts @@ -288,6 +288,22 @@ describe("testing the error handling", () => { }); // ================================= + // ================================= + // HTTP 418 + // --------------------------------- + it("err WCA instance deleted", () => { + const error = mapError( + createError(418, { + code: "error__wca_instance_deleted", + }), + ); + assert.equal( + error.message, + "IBM watsonx Code Assistant instance associated with your Model Id has been deleted. Please contact your administrator.", + ); + }); + // ================================= + // ================================= // HTTP 429 // ---------------------------------