Skip to content

Commit

Permalink
Update some errors to indicate unreachable errors
Browse files Browse the repository at this point in the history
  • Loading branch information
deepjyoti30-st committed Sep 25, 2024
1 parent 71d31e7 commit 3754acb
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions lib/ts/recipe/emailpassword/api/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ export default function getAPIImplementation(): APIInterface {
// in validation but kept here to be safe.
const emailAsUnknown = formFields.filter((f) => f.id === "email")[0].value;
if (typeof emailAsUnknown !== "string")
return {
status: "GENERAL_ERROR",
message: "email value needs to be a string",
};
throw new Error("Should never come here since we already check that the email value is a string in validateFormFieldsOrThrowError");
const email: string = emailAsUnknown;

// this function will be reused in different parts of the flow below..
Expand Down Expand Up @@ -464,10 +461,7 @@ export default function getAPIImplementation(): APIInterface {
// in validation but kept here to be safe.
const newPasswordAsUnknown = formFields.filter((f) => f.id === "password")[0].value;
if (typeof newPasswordAsUnknown !== "string")
return {
status: "GENERAL_ERROR",
message: "password value needs to be a string",
};
throw new Error("Should never come here since we already check that the password value is a string in validateFormFieldsOrThrowError");
let newPassword: string = newPasswordAsUnknown;

let tokenConsumptionResponse = await options.recipeImplementation.consumePasswordResetToken({
Expand Down Expand Up @@ -657,16 +651,10 @@ export default function getAPIImplementation(): APIInterface {
// check for type is done in a parent function but they are kept
// here to be on the safe side.
if (typeof emailAsUnknown !== "string")
return {
status: "GENERAL_ERROR",
message: "email value needs to be a string",
};
throw new Error("Should never come here since we already check that the email value is a string in validateFormFieldsOrThrowError");

if (typeof passwordAsUnknown !== "string")
return {
status: "GENERAL_ERROR",
message: "password value needs to be a string",
};
throw new Error("Should never come here since we already check that the password value is a string in validateFormFieldsOrThrowError");

let email: string = emailAsUnknown;
let password: string = passwordAsUnknown;
Expand Down Expand Up @@ -828,16 +816,10 @@ export default function getAPIImplementation(): APIInterface {
// check for type is done in a parent function but they are kept
// here to be on the safe side.
if (typeof emailAsUnknown !== "string")
return {
status: "GENERAL_ERROR",
message: "email value needs to be a string",
};
throw new Error("Should never come here since we already check that the email value is a string in validateFormFieldsOrThrowError");

if (typeof passwordAsUnknown !== "string")
return {
status: "GENERAL_ERROR",
message: "password value needs to be a string",
};
throw new Error("Should never come here since we already check that the password value is a string in validateFormFieldsOrThrowError");

let email: string = emailAsUnknown;
let password: string = passwordAsUnknown;
Expand Down

0 comments on commit 3754acb

Please sign in to comment.