From 16f404860425ae38c56e14d595401de6ec68e2fb Mon Sep 17 00:00:00 2001 From: Siddharth Singh Date: Tue, 6 Aug 2024 01:25:39 +0530 Subject: [PATCH] way better logging --- src/controllers/frontend.ts | 9 ++++----- src/utils/og-metadata.ts | 7 ++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/controllers/frontend.ts b/src/controllers/frontend.ts index 75d09627..72e3931d 100644 --- a/src/controllers/frontend.ts +++ b/src/controllers/frontend.ts @@ -36,7 +36,6 @@ async function buildTemplateOpts(params: PathParams, url: string): Promise { try { const content = await Deno.readTextFile(new URL('../../public/index.html', import.meta.url)); const ua = c.req.header('User-Agent'); - console.debug('got ua', ua); + console.debug('ua', ua); if (!SHOULD_INJECT_RE.test(ua || '')) { return c.html(content); } @@ -88,7 +87,7 @@ export const frontendController: AppMiddleware = async (c, next) => { const meta = metadataView(await buildTemplateOpts(params, Conf.local(c.req.path))); return c.html(content.replace(META_PLACEHOLDER, meta)); } catch (e) { - console.log(e); + console.log(`Error in building meta tags: ${e}`); return c.html(content); } } diff --git a/src/utils/og-metadata.ts b/src/utils/og-metadata.ts index 62717113..f1b65a57 100644 --- a/src/utils/og-metadata.ts +++ b/src/utils/og-metadata.ts @@ -115,7 +115,8 @@ export async function getHandle(id: string, acc?: ProfileInfo) { if (author?.meta?.nip05) return parseNip05(author.meta.nip05).handle; else if (author?.meta?.name) return author.meta.name; } catch (e) { - console.debug('Error in getHandle: ', e); + console.debug('Error fetching profile/parsing nip-05 in getHandle'); + console.debug(e); } return fallback; }; @@ -148,8 +149,8 @@ export async function getStatusInfo(id: string): Promise { try { const handle = await getHandle(event.pubkey); title = `View @${handle}'s post on Ditto`; - } catch (e) { - console.log(e); + } catch (_) { + console.log(`Error getting status info for ${id}: proceeding silently`); } const res: StatusInfo = { title,