From 427825b18693931ba6106705a0fb17b1c0ebf486 Mon Sep 17 00:00:00 2001 From: Rafi Arrafif Date: Thu, 19 Feb 2026 16:46:21 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20fix:=20add=20error=20handling=20?= =?UTF-8?q?for=20GitHub=20auth=20request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/githubRequest.controller.ts | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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); + } };