From bdbd14c560f63bd2b24c0c7a7ce2be63b7fd760c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Wed, 13 Mar 2024 10:04:43 +0000 Subject: [PATCH] Fix next edge runtime not liking error in logs (#247) * Fix next edge runtime not liking error in logs * Fix other errors --- src/lib/api.ts | 6 +++++- src/lib/async.ts | 2 +- src/lib/images.ts | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lib/api.ts b/src/lib/api.ts index e407107ed..71fe4e734 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -433,7 +433,11 @@ export async function getSpaceCustomization(spaceId: string): Promise>(extend); return { ...raw, ...parsed }; } catch (error) { - console.error('Failed to parse x-gitbook-customization header (ignored)', error); + console.error( + `Failed to parse x-gitbook-customization header (ignored): ${ + (error as Error).stack ?? (error as Error).message ?? error + }`, + ); } } diff --git a/src/lib/async.ts b/src/lib/async.ts index f58ea547d..eefc98d76 100644 --- a/src/lib/async.ts +++ b/src/lib/async.ts @@ -208,7 +208,7 @@ function logIgnoredError(message: string, error: Error) { return; } - console.error(message, error); + console.error(`${message}: ${error.stack ?? error.message ?? error}`); } const UndefinedSymbol = Symbol('Undefined'); diff --git a/src/lib/images.ts b/src/lib/images.ts index 2f65f0b18..6bf6ba7cd 100644 --- a/src/lib/images.ts +++ b/src/lib/images.ts @@ -108,7 +108,11 @@ export async function getImageSize( height: json.original.height, }; } catch (error) { - console.error(`failed to fetch image size for ${input}`, error); + console.error( + `failed to fetch image size for ${input}: ${ + (error as Error).stack ?? (error as Error).message ?? error + }`, + ); return null; } }