Error formatting fails when referring to dynamically generated code
gajus opened this issue · comments
Current behaviour
A code fragment thats generated during the compilation step causes an error when formatting erro stack trace using formatErrorStack
, e.g.
The following code fragment:
(foo: string) => {}
when compiled using babel-plugin-tcomb gets convered to (pseudo code):
(foo) => {
require('tcomb').String(foo);
}
If a stack trace includes the generated line code, then getOriginalPosition
(dependency of formatErrorStack
) will fail with an error:
TypeError: Cannot read property 'replace' of null
at getOriginalPosition (/node_modules/isomorphic-webpack/dist/factories/createIsomorphicWebpack.js:103:38)
at errorStack.replace (/node_modules/isomorphic-webpack/dist/factories/createIsomorphicWebpack.js:111:32)
at RegExp.[Symbol.replace] (native)
at RegExp.[Symbol.replace] (native)
at String.replace (native)
at formatErrorStack (/node_modules/isomorphic-webpack/dist/factories/createIsomorphicWebpack.js:110:23)
at /src/bin/server.js:66:17
at Layer.handle_error (/node_modules/router/lib/layer.js:69:5)
at trim_prefix (/node_modules/router/index.js:327:13)
at /node_modules/router/index.js:293:7
Expected behaviour
Stack trace must refer to the original code executed in the VM.