Skip to content

Commit

Permalink
ElmTransformer: Catch error from compiler and re-throw as diagnostic. (
Browse files Browse the repository at this point in the history
  • Loading branch information
JensPfeifle committed Nov 28, 2021
1 parent 269b8f4 commit be65b92
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/transformers/elm/src/ElmTransformer.js
Expand Up @@ -56,8 +56,19 @@ export default (new Transformer({
// this can be removed after https://github.com/isaacs/node-graceful-fs/pull/200 was mergend and used in parcel
// $FlowFixMe[method-unbinding]
process.chdir.disabled = isWorker;
let code;
try {
code = await compileToString(elm, elmBinary, asset, compilerConfig);
} catch (e) {
throw new ThrowableDiagnostic({
diagnostic: {
message: 'Compilation failed',
origin: '@parcel/elm-transformer',
stack: e.toString(),
},
});
}

let code = await compileToString(elm, elmBinary, asset, compilerConfig);
if (options.hmrOptions) {
code = elmHMR.inject(code);
}
Expand Down

0 comments on commit be65b92

Please sign in to comment.