mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Improve bundling error message formatting (#55794)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
1 parent
d6042d2161
commit
b2efda00a8
1 file changed
+13
-3
+13
-3
@@ -52,9 +52,19 @@ export async function createBundle(options: BundleOptions): Promise<void> {
|
||||
);
|
||||
|
||||
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(
|
||||
|
||||
Reference in new issue
Block a user