Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
chore: updated the catch block.
  • Loading branch information
hanoak20 committed Feb 20, 2024
commit 1aa66e26d135c251f87b6db68f2704ca974d0b04
2 changes: 1 addition & 1 deletion src/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const login = async (req: Request): Promise<LoginServiceType> => {
logger.error(getLogMessage(srcFun, "Error while logging in", {}, error));
throw new ExceptionFunction(
error?.message || HTTP_TEXTS.INTERNAL_ERROR,
error?.status || HTTP_CODES.SERVER_ERROR
error?.statusCode || error?.status || HTTP_CODES.SERVER_ERROR
);
}
};
Expand Down
19 changes: 14 additions & 5 deletions src/services/org.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import https from "../utils/https.utils";
import { LoginServiceType } from "../models/types";
import getAuthtoken from "../utils/auth.utils";
import logger from "../utils/logger";
import { HTTP_TEXTS } from "../constants";
import { InternalServerError } from "../utils/custom-errors.utils";
import { HTTP_TEXTS, HTTP_CODES } from "../constants";
import { ExceptionFunction } from "../utils/custom-errors.utils";

const getAllStacks = async (req: Request): Promise<LoginServiceType> => {
const srcFun = "getAllStacks";
Expand Down Expand Up @@ -68,7 +68,10 @@ const getAllStacks = async (req: Request): Promise<LoginServiceType> => {
)
);

throw new InternalServerError();
throw new ExceptionFunction(
error?.message || HTTP_TEXTS.INTERNAL_ERROR,
error?.statusCode || error?.status || HTTP_CODES.SERVER_ERROR
);
}
};

Expand Down Expand Up @@ -133,7 +136,10 @@ const createStack = async (req: Request): Promise<LoginServiceType> => {
)
);

throw new InternalServerError();
throw new ExceptionFunction(
error?.message || HTTP_TEXTS.INTERNAL_ERROR,
error?.statusCode || error?.status || HTTP_CODES.SERVER_ERROR
);
}
};

Expand Down Expand Up @@ -184,7 +190,10 @@ const getLocales = async (req: Request): Promise<LoginServiceType> => {
getLogMessage(srcFun, "Error while getting locales", token_payload, error)
);

throw new InternalServerError();
throw new ExceptionFunction(
error?.message || HTTP_TEXTS.INTERNAL_ERROR,
error?.statusCode || error?.status || HTTP_CODES.SERVER_ERROR
);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const getUserProfile = async (req: Request): Promise<LoginServiceType> => {
);
throw new ExceptionFunction(
error?.message || HTTP_TEXTS.INTERNAL_ERROR,
error?.status || HTTP_CODES.SERVER_ERROR
error?.statusCode || error?.status || HTTP_CODES.SERVER_ERROR
);
}
};
Expand Down