From df7bd456102f3e30c26a02c770d7e251dffc9892 Mon Sep 17 00:00:00 2001 From: Mark Suckerberg Date: Mon, 11 Mar 2024 23:35:16 -0500 Subject: [PATCH] Makes errors a little cleaner --- src/index.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/index.ts b/src/index.ts index 04a2537..a5828f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -217,37 +217,31 @@ async function errorPage(error: unknown, url: URL) { return new Response('Unknown error fetching post', { status: 500 }); } - const errorDescription = - error.response.meta.status === 303 - ? "Login required to view this account's posts" - : error.response.meta.msg; + const errorDetail = error.response.errors?.at(0)?.detail; + const errorDescription = error.response.meta.msg + (errorDetail ? `: ${errorDetail}` : ''); const html = ` txTumblr - + - + - + - - -

Error ${error.response.meta.status}: ${error.response.meta.msg}

-

${error.response.errors?.at(0)?.detail}

- - `; + + `; return new Response(html, { headers: {