Skip to content

Commit

Permalink
Update msg for WCA model not found error and create a new error no de…
Browse files Browse the repository at this point in the history
…fault WCA model
  • Loading branch information
TamiTakamiya committed May 15, 2024
1 parent ec5b72e commit ed3f145
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/features/lightspeed/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,18 @@ ERRORS.addError(
"Could not find an API Key for IBM watsonx Code Assistant. Please contact your administrator.",
),
);
ERRORS.addError(
403,
new Error(
"error__no_default_model_id",
"Ansible Lightspeed does not have a model configured. Contact your Ansible administrator to configure a model, or specify a model in your Ansible extension settings under Lightspeed: Model Id Override.",
),
);
ERRORS.addError(
403,
new Error(
"error__wca_model_id_not_found",
"Could not find a Model Id for IBM watsonx Code Assistant. Please contact your administrator.",
"Your organization does not have an IBM watsonx Code Assistant model configured. Contact your Red Hat organization administrator to configure a model, or specify a model in your Ansible extension settings under Lightspeed: Model Id Override.",
),
);
ERRORS.addError(
Expand Down
14 changes: 13 additions & 1 deletion test/units/lightspeed/handleApiError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,18 @@ describe("testing the error handling", () => {
);
});

it("err no default WCA Model Id found", () => {
const error = mapError(
createError(403, {
code: "error__no_default_model_id",
}),
);
assert.equal(
error.message,
"Ansible Lightspeed does not have a model configured. Contact your Ansible administrator to configure a model, or specify a model in your Ansible extension settings under Lightspeed: Model Id Override.",
);
});

it("err WCA Model Id missing", () => {
const error = mapError(
createError(403, {
Expand All @@ -277,7 +289,7 @@ describe("testing the error handling", () => {
);
assert.equal(
error.message,
"Could not find a Model Id for IBM watsonx Code Assistant. Please contact your administrator.",
"Your organization does not have an IBM watsonx Code Assistant model configured. Contact your Red Hat organization administrator to configure a model, or specify a model in your Ansible extension settings under Lightspeed: Model Id Override.",
);
});

Expand Down

0 comments on commit ed3f145

Please sign in to comment.