Browse Source

include module ID in error message (#143)

better-aggressive
Rich Harris 9 years ago
parent
commit
7397b37a6d
  1. 1
      src/Module.js
  2. 8
      test/function/reports-syntax-error-locations/_config.js
  3. 1
      test/function/reports-syntax-error-locations/main.js

1
src/Module.js

@ -500,6 +500,7 @@ export default class Module {
} catch ( err ) {
err.code = 'PARSE_ERROR';
err.file = this.id; // see above - not necessarily true, but true enough
err.message += ` in ${this.id}`;
throw err;
}
}

8
test/function/reports-syntax-error-locations/_config.js

@ -0,0 +1,8 @@
var assert = require( 'assert' );
module.exports = {
description: 'reports syntax error filename',
error: function ( err ) {
assert.ok( /in .+main\.js/.test( err.message ) );
}
};

1
test/function/reports-syntax-error-locations/main.js

@ -0,0 +1 @@
var 42 = answer;
Loading…
Cancel
Save