Always report filename

Reviewed By: cpojer

Differential Revision: D5764824

fbshipit-source-id: cb90e429176764d4a1043fd57bbfee223361a182
This commit is contained in:
Miguel Jimenez Esun 2017-09-04 13:39:18 -07:00 committed by Facebook Github Bot
parent 6e415bcb2f
commit 2377f04f4a
2 changed files with 5 additions and 2 deletions

View File

@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @emails oncall+javascript_tools
* @format
*/
'use strict';
@ -100,7 +101,9 @@ describe('Transformer', function() {
.transformFile(fileName, localPath, '', {})
.catch(function(error) {
expect(error.type).toEqual('TransformError');
expect(error.message).toBe('SyntaxError ' + message);
expect(error.message).toBe(
'SyntaxError in /an/arbitrary/file.js: ' + message,
);
expect(error.lineNumber).toBe(2);
expect(error.column).toBe(15);
expect(error.filename).toBe(fileName);

View File

@ -224,7 +224,7 @@ function formatGenericError(err, filename) {
function formatBabelError(err, filename) {
var error = new TransformError();
error.type = 'TransformError';
error.message = (err.type || error.type) + ' ' + err.message;
error.message = `${err.type || error.type} in ${filename}: ${err.message}`;
error.stack = err.stack;
error.snippet = err.codeFrame;
error.lineNumber = err.loc.line;