diff --git a/src/modules/auth/controllers/githubRequest.controller.ts b/src/modules/auth/controllers/githubRequest.controller.ts index 06709dc..fc1a3bd 100644 --- a/src/modules/auth/controllers/githubRequest.controller.ts +++ b/src/modules/auth/controllers/githubRequest.controller.ts @@ -1,12 +1,22 @@ import { Context } from "elysia"; import { returnReadResponse } from "../../../helpers/callback/httpResponse"; import { githubRequestService } from "../services/http/githubRequest.service"; +import { mainErrorHandler } from "../../../helpers/error/handler"; export const githubRequestController = async ( - ctx: Context & { query: { callback?: string } } + ctx: Context & { query: { callback?: string } }, ) => { - const loginUrl = await githubRequestService(ctx.query.callback); - return returnReadResponse(ctx.set, 200, "Login URL generated successfully", { - endpointUrl: loginUrl, - }); + try { + const loginUrl = await githubRequestService(ctx.query.callback); + return returnReadResponse( + ctx.set, + 200, + "Login URL generated successfully", + { + endpointUrl: loginUrl, + }, + ); + } catch (error) { + return mainErrorHandler(ctx.set, error); + } };