From 6bd6e410ee88c354d610bd87455b1d6af57650fd Mon Sep 17 00:00:00 2001 From: Nick Lefever Date: Thu, 26 Feb 2026 19:14:37 -0800 Subject: [PATCH] Improve bundling error message formatting Summary: Format the error messages coming from bundling to mainting the formatting and make these easier to read. Changelog: [Internal] Differential Revision: D94611951 --- private/react-native-fantom/runner/bundling.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/private/react-native-fantom/runner/bundling.js b/private/react-native-fantom/runner/bundling.js index cb57a93dc816..de334ec28ccd 100644 --- a/private/react-native-fantom/runner/bundling.js +++ b/private/react-native-fantom/runner/bundling.js @@ -52,9 +52,19 @@ export async function createBundle(options: BundleOptions): Promise { ); if (lastBundleError || lastBundleResult?.ok !== true) { - throw new Error( - `Failed to request bundle from Metro: ${lastBundleError?.message ?? (await lastBundleResult?.text()) ?? ''}`, - ); + let errorMessage = + lastBundleError?.message ?? (await lastBundleResult?.text()) ?? ''; + + try { + const parsed = JSON.parse(errorMessage); + if (typeof parsed.message === 'string') { + errorMessage = parsed.message; + } + } catch { + // Not JSON — use the raw text as-is. + } + + throw new Error(`Failed to request bundle from Metro:\n${errorMessage}`); } await fs.promises.writeFile(