Skip to content

Commit

Permalink
AAP-36462: [r11]: Add support for HTTP422 response (#1672)
Browse files Browse the repository at this point in the history
  • Loading branch information
manstis authored Nov 25, 2024
1 parent fd6d8fd commit 06f3806
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/features/lightspeed/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,20 @@ ERRORS.addError(
),
);
ERRORS.addError(400, new Error("error__feedback_validation"));
ERRORS.addError(
400,
new Error(
"error__wca_inference_failure",
"IBM watsonx Code Assistant inference failed. Please check your input and try again.",
),
);
ERRORS.addError(
400,
new Error(
"error__wca_validation_failure",
"IBM watsonx Code Assistant failed to validate the response from the model. Please check your input and try again.",
),
);

ERRORS.addError(
403,
Expand Down
28 changes: 28 additions & 0 deletions test/units/lightspeed/utils/handleApiError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,34 @@ describe("testing the error handling", () => {
);
assert.equal(error.message, "A field was invalid.");
});

it("err WCA inference failure", () => {
const error = mapError(
createError(400, {
code: "error__wca_inference_failure",
message:
"IBM watsonx Code Assistant inference failed. Please check your input and try again.",
}),
);
assert.equal(
error.message,
"IBM watsonx Code Assistant inference failed. Please check your input and try again.",
);
});

it("err WCA validation failure", () => {
const error = mapError(
createError(400, {
code: "error__wca_validation_failure",
detail: { reason: "error 1" },
}),
);
assert.equal(
error.message,
"IBM watsonx Code Assistant failed to validate the response from the model. Please check your input and try again.",
);
assert.equal(error.detail, "reason: error 1");
});
// =================================

// =================================
Expand Down

0 comments on commit 06f3806

Please sign in to comment.