Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

refactor: replace console.error with logger for improved error handling (#5995)

authored by yoginth.com and committed by

GitHub 1984f984 14866fd3

+26 -12
+2 -1
apps/api/src/utils/handleApiError.ts
··· 1 1 import { Status } from "@hey/data/enums"; 2 2 import { ERRORS } from "@hey/data/errors"; 3 + import logger from "@hey/helpers/logger"; 3 4 import type { Context } from "hono"; 4 5 5 6 const handleApiError = (ctx: Context, error?: unknown): Response => { 6 - console.error(error); 7 + logger.error(error); 7 8 8 9 return ctx.json( 9 10 { error: ERRORS.SomethingWentWrong, status: Status.Error },
+22 -10
apps/api/src/utils/syncAddressesToGuild.ts
··· 1 1 import { createGuildClient, createSigner } from "@guildxyz/sdk"; 2 2 import { Status } from "@hey/data/enums"; 3 + import logger from "@hey/helpers/logger"; 3 4 import signer from "./signer"; 4 5 5 6 const guildClient = createGuildClient("heyxyz"); ··· 22 23 requirementId: number; 23 24 roleId: number; 24 25 }) => { 25 - const updatedRequirement = await requirementClient.update( 26 - 7465, 27 - roleId, 28 - requirementId, 29 - { data: { addresses, hideAllowlist: true }, visibility: "PUBLIC" }, 30 - signerFunction 31 - ); 32 - 33 - return { 26 + // Return immediately with success status 27 + const result = { 34 28 status: Status.Success, 35 29 total: addresses.length, 36 - updatedAt: updatedRequirement.updatedAt 30 + updatedAt: new Date().toISOString() 37 31 }; 32 + 33 + // Run the sync operation in the background without awaiting 34 + requirementClient 35 + .update( 36 + 7465, 37 + roleId, 38 + requirementId, 39 + { data: { addresses, hideAllowlist: true }, visibility: "PUBLIC" }, 40 + signerFunction 41 + ) 42 + .then(() => { 43 + logger.info("Guild sync completed"); 44 + }) 45 + .catch((error) => { 46 + logger.error("Guild sync failed:", error); 47 + }); 48 + 49 + return result; 38 50 }; 39 51 40 52 export default syncAddressesToGuild;
+2 -1
apps/web/src/components/Common/ErrorBoundary.tsx
··· 1 + import logger from "@hey/helpers/logger"; 1 2 import type { ErrorInfo, ReactNode } from "react"; 2 3 import { Component } from "react"; 3 4 import SiteError from "@/components/Shared/SiteError"; ··· 22 23 } 23 24 24 25 public componentDidCatch(error: Error, errorInfo: ErrorInfo) { 25 - console.error("Uncaught error:", error, errorInfo); 26 + logger.error("Uncaught error:", error, errorInfo); 26 27 } 27 28 28 29 public render() {