From 2b80cdf1bba3b756915117139474440c203cbd8d Mon Sep 17 00:00:00 2001 From: James Ide Date: Tue, 16 Jan 2018 03:22:32 -0800 Subject: [PATCH] Fix HMR syntax error messages (`message` instead of `description`) Summary: The code to display HMR errors on the client was reading the `description` field from Metro payloads. Metro does not include `description` in the body of its error payloads -- only in its `body.errors[]` items. This commit changes RN's HMR code to show `body.message` (set consistently with https://github.com/facebook/metro/pull/124) instead of the non-existent `body.description`. Open a test RN app, enable HMR, and then introduce a syntax error in an app source file. See that the redbox provides information about the syntax error instead of just saying "TransformError undefined". - https://github.com/facebook/metro/pull/124 [GENERAL][ENHANCEMENT][HMR] - Fix display of syntax error messages when HMR is enabled Closes https://github.com/facebook/react-native/pull/17619 Differential Revision: D6726516 Pulled By: mjesun fbshipit-source-id: b1d1008d6f1aa8f88ff8a2aa1374724a305c773b --- Libraries/Utilities/HMRClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Utilities/HMRClient.js b/Libraries/Utilities/HMRClient.js index 53cb874c1d..4934c4ff42 100644 --- a/Libraries/Utilities/HMRClient.js +++ b/Libraries/Utilities/HMRClient.js @@ -121,7 +121,7 @@ Error: ${e.message}` } case 'error': { HMRLoadingView.hide(); - throw new Error(data.body.type + ' ' + data.body.description); + throw new Error(`${data.body.type}: ${data.body.message}`); } default: { throw new Error(`Unexpected message: ${data}`);