Skip to content

Commit b2efda0

Browse files
Nick Lefevermeta-codesync[bot]
authored andcommitted
Improve bundling error message formatting (#55794)
Summary: Pull Request resolved: #55794 Format the error messages coming from bundling to mainting the formatting and make these easier to read. Changelog: [Internal] Reviewed By: javache Differential Revision: D94611951 fbshipit-source-id: cbb8b2d1ff517b5487d4b799b1e2e3476629f84c
1 parent d6042d2 commit b2efda0

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

private/react-native-fantom/runner/bundling.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,19 @@ export async function createBundle(options: BundleOptions): Promise<void> {
5252
);
5353

5454
if (lastBundleError || lastBundleResult?.ok !== true) {
55-
throw new Error(
56-
`Failed to request bundle from Metro: ${lastBundleError?.message ?? (await lastBundleResult?.text()) ?? ''}`,
57-
);
55+
let errorMessage =
56+
lastBundleError?.message ?? (await lastBundleResult?.text()) ?? '';
57+
58+
try {
59+
const parsed = JSON.parse(errorMessage);
60+
if (typeof parsed.message === 'string') {
61+
errorMessage = parsed.message;
62+
}
63+
} catch {
64+
// Not JSON — use the raw text as-is.
65+
}
66+
67+
throw new Error(`Failed to request bundle from Metro:\n${errorMessage}`);
5868
}
5969

6070
await fs.promises.writeFile(

0 commit comments

Comments
 (0)